本文整理汇总了C++中MathVector::magnitude方法的典型用法代码示例。如果您正苦于以下问题:C++ MathVector::magnitude方法的具体用法?C++ MathVector::magnitude怎么用?C++ MathVector::magnitude使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MathVector
的用法示例。
在下文中一共展示了MathVector::magnitude方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setFromCorners
void Bezier::setFromCorners(const MathVector<float, 3>& fl, const MathVector<float, 3>& fr,
const MathVector<float, 3>& bl, const MathVector<float, 3>& br) {
MathVector<float, 3> temp;
center = fl + fr + bl + br; center = center * 0.25;
radius = 0;
if ((fl - center).magnitude() > radius) radius = (fl - center).magnitude();
if ((fr - center).magnitude() > radius) radius = (fr - center).magnitude();
if ((bl - center).magnitude() > radius) radius = (bl - center).magnitude();
if ((br - center).magnitude() > radius) radius = (br - center).magnitude();
// Assign corners
points[0][0] = fl;
points[0][3] = fr;
points[3][3] = br;
points[3][0] = bl;
// Calculate intermediate front and back points
temp = fr - fl;
if (temp.magnitude() < 0.0001) {
points[0][1] = fl;
points[0][2] = fl;
} else {
points[0][1] = fl + temp.normalized() * (temp.magnitude() / 3.0);
points[0][2] = fl + temp.normalized() * (2.0 * temp.magnitude() / 3.0);
}
temp = br - bl;
if (temp.magnitude() < 0.0001) {
points[3][1] = bl;
points[3][2] = bl;
} else {
points[3][1] = bl + temp.normalized() * (temp.magnitude() / 3.0);
points[3][2] = bl + temp.normalized() * (2.0 * temp.magnitude() / 3.0);
}
// Calculate intermediate left and right points
int i;
for (i = 0; i < 4; ++i) {
temp = points[3][i] - points[0][i];
if (temp.magnitude() > 0.0001) {
points[1][i] = points[0][i] + temp.normalized() * (temp.magnitude() / 3.0);
points[2][i] = points[0][i] + temp.normalized() * (2.0 * temp.magnitude() / 3.0);
} else {
points[1][i] = points[0][i];
points[2][i] = points[0][i];
}
}
}