예제 #1
0
    // The smaller of the two possible angles between the two vectors is returned, therefore the result will never be greater than 180 degrees or smaller than -180 degrees.
    // If you imagine the from and to vectors as lines on a piece of paper, both originating from the same point, then the /axis/ vector would point up out of the paper.
    // The measured angle between the two vectors would be positive in a clockwise direction and negative in an anti-clockwise direction.
    public static Fix64 SignedAngle(FixVector3 from, FixVector3 to, FixVector3 axis)
    {
        FixVector3 fromNorm = from.Normalized, toNorm = to.Normalized;
        Fix64      unsignedAngle = FixMath.Acos(FixMath.Clamp(Dot(fromNorm, toNorm), -Fix64.ONE, Fix64.ONE)) * FixMath.Rad2Deg;
        Fix64      sign          = FixMath.Sign(Dot(axis, Cross(fromNorm, toNorm)));

        return(unsignedAngle * sign);
    }
예제 #2
0
 // Returns the angle in degrees between /from/ and /to/. This is always the smallest
 public static Fix64 Angle(FixVector3 from, FixVector3 to)
 {
     return(FixMath.Acos(FixMath.Clamp(Dot(from.Normalized, to.Normalized), -Fix64.ONE, Fix64.ONE)) * FixMath.Rad2Deg);
 }