Beispiel #1
0
    public static Int3 changeAbsolute2Relative(Int3 point, Int3 originPoint, ushort angle)
    {
        //originPoint为图中A点,directionPoint为图中B点,changePoint为图中C点
        Int3 rePoint = new Int3();

        Int3 directionPoint = FixMath.DecomposeAngle(1000, angle);

        directionPoint.x = originPoint.x + directionPoint.x;
        directionPoint.y = originPoint.y + directionPoint.y;
        directionPoint.y = originPoint.z + directionPoint.z;

        if (originPoint == directionPoint) //方向点跟原点重合,就用平行于原坐标的x轴来算就行了
        {                                  //AB点重合,方向指向哪里都没所谓,肯定按原来的做方便
            rePoint.x = point.x - originPoint.x;
            rePoint.y = point.y - originPoint.y;
        }
        else
        {
            //计算三条边
            //计算三条边
            Fix64 a = (Fix64)DistanceSqr(directionPoint, point);
            a = Fix64.Sqrt(a);
            Fix64 b = (Fix64)DistanceSqr(point, originPoint);
            b = Fix64.Sqrt(b);
            Fix64 c = (Fix64)DistanceSqr(directionPoint, originPoint);
            c = Fix64.Sqrt(c);

            Fix64 cosA = (b * b + c * c - a * a) / ((Fix64)2 * b * c); //余弦
            Fix64 xpos = a * cosA;                                     //相对坐标x
            Fix64 ypos = Fix64.Sqrt(a * a - xpos * xpos);              //相对坐标y

            rePoint.x = (int)xpos;
            rePoint.y = (int)ypos;
        }
        return(rePoint);
    }
Beispiel #2
0
    private Vector3 GetU3DForwards()
    {
        Int3 perform = FixMath.DecomposeAngle(1000, angle);

        return(perform.ToVector3());
    }