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
/*!
Shinya Kitaoka 120a6e
  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
Shinya Kitaoka 120a6e
  \par aSpeed the tangent vector in a (that is the first control point minus the
Shinya Kitaoka 120a6e
  second)
Toshihiro Shimizu 890ddd
  \par b the third control point
Shinya Kitaoka 120a6e
  \par bSpeed the tangent vector in b (that is the third control point minus the
Shinya Kitaoka 120a6e
  fourth)
Shinya Kitaoka 120a6e
  \ret the parameter value u0 of the Bezier curve C(u) for x, that is C(u0) =
Shinya Kitaoka 120a6e
  (x,y)
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka 120a6e
DVAPI double invCubicBezierX(double x, const TPointD &a, const TPointD &aSpeed,
Shinya Kitaoka 120a6e
                             const TPointD &bSpeed, 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
Shinya Kitaoka 120a6e
  \par aSpeed the tangent vector in a (that is the first control point minus the
Shinya Kitaoka 120a6e
  second)
Toshihiro Shimizu 890ddd
  \par b the third control point
Shinya Kitaoka 120a6e
  \par bSpeed the tangent vector in b (that is the third control point minus the
Shinya Kitaoka 120a6e
  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
*/
Shinya Kitaoka 120a6e
DVAPI double getCubicBezierY(double x, const TPointD &a, const TPointD &aSpeed,
Shinya Kitaoka 120a6e
                             const TPointD &bSpeed, 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
Shinya Kitaoka 120a6e
  \par aSpeed the tangent vector in a (that is the first control point minus the
Shinya Kitaoka 120a6e
  second)
Toshihiro Shimizu 890ddd
  \par b the third control point
Shinya Kitaoka 120a6e
  \par bSpeed the tangent vector in b (that is the third control point minus the
Shinya Kitaoka 120a6e
  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,>
Shinya Kitaoka 120a6e
                                                        const TPointD &aSpeed,
Shinya Kitaoka 120a6e
                                                        const TPointD &bSpeed,
Shinya Kitaoka 120a6e
                                                        const TPointD &b);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // TCUBICBEZIER_INCLUDED
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------