本文整理汇总了C++中BEZIER::SurfCoord方法的典型用法代码示例。如果您正苦于以下问题:C++ BEZIER::SurfCoord方法的具体用法?C++ BEZIER::SurfCoord怎么用?C++ BEZIER::SurfCoord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BEZIER
的用法示例。
在下文中一共展示了BEZIER::SurfCoord方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Attach
void BEZIER::Attach(BEZIER & other, bool reverse)
{
/*if (!reverse)
{
//move the other patch to the location of this patch and force its
// intermediate points into a nice grid layout
other.SetFromCorners(other.points[0][0], other.points[0][3], points[0][0], points[0][3]);
for (int x = 0; x < 4; x++)
{
//slope points in the forward direction
MATHVECTOR<float,3> slope = other.points[0][x] - points[3][x];
if (slope.Magnitude() > 0.0001)
slope = slope.Normalize();
float otherlen = (other.points[0][x] - other.points[3][x]).Magnitude();
float mylen = (points[0][x] - points[3][x]).Magnitude();
float meanlen = (otherlen + mylen)/2.0;
float leglen = meanlen / 3.0;
if (slope.Magnitude() > 0.0001)
{
other.points[2][x] = other.points[3][x] + slope*leglen;
points[1][x] = points[0][x] + slope*(-leglen);
}
else
{
other.points[2][x] = other.points[3][x];
points[1][x] = points[0][x];
}
}
}*/
//CheckForProblems();
//store the pointer to next patch
next_patch = &other;
//calculate the track radius at the connection of this patch and next patch
MATHVECTOR<float,3> a = SurfCoord(0.5,0.0);
MATHVECTOR<float,3> b = SurfCoord(0.5,1.0);
MATHVECTOR<float,3> c = other.SurfCoord(0.5,1.0);
if (reverse)
{
a = SurfCoord(0.5,1.0);
b = SurfCoord(0.5,0.0);
c = other.SurfCoord(0.5,0.0);
//Reverse();
}
//racing_line = a;
MATHVECTOR<float,3> d1 = a - b;
MATHVECTOR<float,3> d2 = c - b;
float diff = d2.Magnitude() - d1.Magnitude();
double dd = ((d1.Magnitude() < 0.0001) || (d2.Magnitude() < 0.0001)) ? 0.0 : d1.Normalize().dot(d2.Normalize());
float angle = acos((dd>=1.0L)?1.0L:(dd<=-1.0L)?-1.0L:dd);
float d1d2mag = d1.Magnitude() + d2.Magnitude();
float alpha = (d1d2mag < 0.0001) ? 0.0f : (M_PI * diff + 2.0 * d1.Magnitude() * angle) / d1d2mag / 2.0;
if (fabs(alpha - M_PI/2.0) < 0.001) track_radius = 10000.0;
else track_radius = d1.Magnitude() / 2.0 / cos(alpha);
if (d1.Magnitude() < 0.0001)
track_curvature = 0.0;
else
track_curvature = 2.0 * cos(alpha) / d1.Magnitude();
//determine it's a left or right turn at the connection
MATHVECTOR<float,3> d = d1.cross(d2);
if (fabs(d[0]) < 0.1 && fabs(d[1]) < 0.1 && fabs(d[2]) < 0.1)
{
turn = 0; //straight ahead
}
else if (d[1] > 0.0) turn = -1; //left turn ahead
else turn = 1; //right turn ahead
//calculate distance from start of the road
if (other.next_patch == NULL || reverse) other.dist_from_start = dist_from_start + d1.Magnitude();
length = d1.Magnitude();
}