本文整理汇总了C++中FloatPoint3D::isZero方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatPoint3D::isZero方法的具体用法?C++ FloatPoint3D::isZero怎么用?C++ FloatPoint3D::isZero使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatPoint3D
的用法示例。
在下文中一共展示了FloatPoint3D::isZero方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gain
double ConeEffect::gain(FloatPoint3D sourcePosition, FloatPoint3D sourceOrientation, FloatPoint3D listenerPosition)
{
if (sourceOrientation.isZero() || ((m_innerAngle == 360.0) && (m_outerAngle == 360.0)))
return 1.0; // no cone specified - unity gain
// Normalized source-listener vector
FloatPoint3D sourceToListener = listenerPosition - sourcePosition;
sourceToListener.normalize();
FloatPoint3D normalizedSourceOrientation = sourceOrientation;
normalizedSourceOrientation.normalize();
// Angle between the source orientation vector and the source-listener vector
double dotProduct = sourceToListener.dot(normalizedSourceOrientation);
double angle = 180.0 * acos(dotProduct) / piDouble;
double absAngle = fabs(angle);
// Divide by 2.0 here since API is entire angle (not half-angle)
double absInnerAngle = fabs(m_innerAngle) / 2.0;
double absOuterAngle = fabs(m_outerAngle) / 2.0;
double gain = 1.0;
if (absAngle <= absInnerAngle)
// No attenuation
gain = 1.0;
else if (absAngle >= absOuterAngle)
// Max attenuation
gain = m_outerGain;
else {
// Between inner and outer cones
// inner -> outer, x goes from 0 -> 1
double x = (absAngle - absInnerAngle) / (absOuterAngle - absInnerAngle);
gain = (1.0 - x) + m_outerGain * x;
}
return gain;
}