本文整理汇总了C++中ThreeDPoint::CrossProduct方法的典型用法代码示例。如果您正苦于以下问题:C++ ThreeDPoint::CrossProduct方法的具体用法?C++ ThreeDPoint::CrossProduct怎么用?C++ ThreeDPoint::CrossProduct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ThreeDPoint
的用法示例。
在下文中一共展示了ThreeDPoint::CrossProduct方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: listenerFrontNorm
// This algorithm is specicied in the webaudio spec.
void
PannerNodeEngine::ComputeAzimuthAndElevation(float& aAzimuth, float& aElevation)
{
ThreeDPoint sourceListener = mPosition - mListenerPosition;
if (sourceListener.IsZero()) {
aAzimuth = 0.0;
aElevation = 0.0;
return;
}
sourceListener.Normalize();
// Project the source-listener vector on the x-z plane.
ThreeDPoint& listenerFront = mListenerOrientation;
ThreeDPoint listenerRightNorm = listenerFront.CrossProduct(mListenerUpVector);
listenerRightNorm.Normalize();
ThreeDPoint listenerFrontNorm(listenerFront);
listenerFrontNorm.Normalize();
ThreeDPoint up = listenerRightNorm.CrossProduct(listenerFrontNorm);
double upProjection = sourceListener.DotProduct(up);
ThreeDPoint projectedSource = sourceListener - up * upProjection;
projectedSource.Normalize();
// Actually compute the angle, and convert to degrees
double projection = projectedSource.DotProduct(listenerRightNorm);
aAzimuth = 180 * acos(projection) / M_PI;
// Compute whether the source is in front or behind the listener.
double frontBack = projectedSource.DotProduct(listenerFrontNorm);
if (frontBack < 0) {
aAzimuth = 360 - aAzimuth;
}
// Rotate the azimuth so it is relative to the listener front vector instead
// of the right vector.
if ((aAzimuth >= 0) && (aAzimuth <= 270)) {
aAzimuth = 90 - aAzimuth;
} else {
aAzimuth = 450 - aAzimuth;
}
aElevation = 90 - 180 * acos(sourceListener.DotProduct(up)) / M_PI;
if (aElevation > 90) {
aElevation = 180 - aElevation;
} else if (aElevation < -90) {
aElevation = -180 - aElevation;
}
}