示例#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 FP SignedAngle(TSVector from, TSVector to, TSVector axis)
        {
            TSVector fromNorm = from.normalized, toNorm = to.normalized;
            FP       unsignedAngle = TSMath.Acos(TSMath.Clamp(Dot(fromNorm, toNorm), -FP.ONE, FP.ONE)) * TSMath.Rad2Deg;
            FP       sign          = TSMath.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 FP Angle(TSVector from, TSVector to)
 {
     return(TSMath.Acos(TSMath.Clamp(Dot(from.normalized, to.normalized), -FP.ONE, FP.ONE)) * TSMath.Rad2Deg);
 }