|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TCUBICBEZIER_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define TCUBICBEZIER_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tmathutil.h"
|
|
Toshihiro Shimizu |
890ddd |
//#include "tcommon.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tgeometry.h"
|
|
Toshihiro Shimizu |
890ddd |
//#include <algorithm></algorithm>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using TConsts::epsilon;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TPARAM_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
Find the value of the parameter u0 of the cubic Bezier curve C(u)
|
|
Toshihiro Shimizu |
890ddd |
for a specified value x, with C(u0) = (x,y).
|
|
Toshihiro Shimizu |
890ddd |
\par x the x-component of a point on the Bezier curve
|
|
Toshihiro Shimizu |
890ddd |
\par a first control point of the Bezier curve
|
|
Toshihiro Shimizu |
890ddd |
\par aSpeed the tangent vector in a (that is the first control point minus the second)
|
|
Toshihiro Shimizu |
890ddd |
\par b the third control point
|
|
Toshihiro Shimizu |
890ddd |
\par bSpeed the tangent vector in b (that is the third control point minus the fourth)
|
|
Toshihiro Shimizu |
890ddd |
\ret the parameter value u0 of the Bezier curve C(u) for x, that is C(u0) = (x,y)
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
DVAPI double invCubicBezierX(double x,
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &a,
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &aSpeed,
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &bSpeed,
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &b);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
for C(u) a cubic Bezier curve, C(u0) = (x,y), find y from x.
|
|
Toshihiro Shimizu |
890ddd |
\par x the x-component of a point on the Bezier curve
|
|
Toshihiro Shimizu |
890ddd |
\par a first control point of the Bezier curve
|
|
Toshihiro Shimizu |
890ddd |
\par aSpeed the tangent vector in a (that is the first control point minus the second)
|
|
Toshihiro Shimizu |
890ddd |
\par b the third control point
|
|
Toshihiro Shimizu |
890ddd |
\par bSpeed the tangent vector in b (that is the third control point minus the fourth)
|
|
Toshihiro Shimizu |
890ddd |
\ret the y-component of a point P(x,y) on the Bezier curve, with C(u0) = P
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
DVAPI double getCubicBezierY(double x,
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &a,
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &aSpeed,
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &bSpeed,
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &b);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
for C(u)=(x,y) a cubic Bezier curve, find minimum and maximum y-values of C(u)
|
|
Toshihiro Shimizu |
890ddd |
\par a first control point of the Bezier curve
|
|
Toshihiro Shimizu |
890ddd |
\par aSpeed the tangent vector in a (that is the first control point minus the second)
|
|
Toshihiro Shimizu |
890ddd |
\par b the third control point
|
|
Toshihiro Shimizu |
890ddd |
\par bSpeed the tangent vector in b (that is the third control point minus the fourth)
|
|
Toshihiro Shimizu |
890ddd |
\ret a pair of points which are the minimum and maximum of the cubic Bezier
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
DVAPI std::pair<tpointd, tpointd=""> getMinMaxCubicBezierY(const TPointD &a,</tpointd,>
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &aSpeed,
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &bSpeed,
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &b);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif //TCUBICBEZIER_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|