예제 #1
0
        public static float AngleBetween(this CameraSpacePoint cur, CameraSpacePoint other)
        {
            float curMag = cur.Magnitude();
            float othMag = other.Magnitude();

            float angle = (float)(Math.Atan(cur.DotProduct(other) / (curMag * othMag)) * 180 / Math.PI);

            return(angle);
        }
예제 #2
0
        public static FaceAngleEuler CalculateFaceAngleColor(CoordSys coordSys, CoordSys newCoord, CoordinateMapper mapper)
        {
            CameraSpacePoint transSide  = coordSys.Center.SubtractFrom(coordSys.Side);
            CameraSpacePoint transFront = coordSys.Center.SubtractFrom(coordSys.Front);
            CameraSpacePoint transTop   = coordSys.Center.SubtractFrom(coordSys.Top);

            CameraSpacePoint transSideN  = newCoord.Center.SubtractFrom(newCoord.Side);
            CameraSpacePoint transFrontN = newCoord.Center.SubtractFrom(newCoord.Front);
            CameraSpacePoint transTopN   = newCoord.Center.SubtractFrom(newCoord.Top);

            CameraSpacePoint transSide2D  = transSide; transSide2D.Y = 0;
            CameraSpacePoint transFront2D = transFront; transFront2D.X = 0;
            CameraSpacePoint transTop2D   = transTop; transTop2D.Z = 0;

            transSide2D  = transSide2D.Norm();
            transFront2D = transFront2D.Norm();
            transTop2D   = transTop2D.Norm();

            CameraSpacePoint transSideN2D  = transSideN; transSideN2D.Y = 0;
            CameraSpacePoint transFrontN2D = transFrontN; transFrontN2D.X = 0;
            CameraSpacePoint transTopN2D   = transTopN; transTopN2D.Z = 0;

            transSideN2D  = transSideN2D.Norm();
            transFrontN2D = transFrontN2D.Norm();
            transTopN2D   = transTopN2D.Norm();


            //FaceAngleEuler angles = new FaceAngleEuler()
            //{
            //    R = (float)(Math.Asin(transTop2D.X * transTopN2D.X) * 180 / Math.PI),
            //    Y = (float)(Math.Asin(transSide2D.Z * transSideN2D.Z) * 180 / Math.PI),
            //    P = (float)(Math.Asin(transFront2D.Y * transFrontN2D.Y) * 180 / Math.PI)
            //};



            FaceAngleEuler angles = new FaceAngleEuler()
            {
                R = (float)(Math.Acos(transTop2D.DotProduct(transTopN2D)) * 180 / Math.PI),
                Y = (float)(Math.Acos(transSide2D.DotProduct(transSideN2D)) * 180 / Math.PI),
                P = (float)(Math.Acos(transFront2D.DotProduct(transFrontN2D)) * 180 / Math.PI)
            };

            return(angles);
        }
예제 #3
0
 public static CameraSpacePoint ProjOperator(this CameraSpacePoint first, CameraSpacePoint sec)
 {
     return(first.Multiply(sec.DotProduct(first) / first.DotProduct(first)));
 }