Exemplo n.º 1
0
    public static _Point RotateByAngle(_Point pnt, _Point Axis, double Angle)
    {
        if (VectMath.IsParallel(pnt, Axis) == true)
        {
            return(pnt);
        }
        Angle = (Angle * Math.PI) / 180;
        _Point Avector     = VectMath.Subtract(pnt, VectMath.Project(pnt, Axis));
        double MagAvector  = VectMath.Magnitude(Avector);
        _Point V1          = VectMath.Unit(VectMath.Cross(Axis, Avector));
        _Point V2          = (VectMath.Negate(Avector));
        _Point TransVector = VectMath.Add(VectMath.Scale(V1, MagAvector * Math.Sin(Angle)), VectMath.Scale(V2, (-1 * Math.Cos(Angle) + 1)));

        return(VectMath.Add(TransVector, pnt));
    }
Exemplo n.º 2
0
        public Point convert2D(_Point p)
        {
            if (Camera1.NormalAxis != Axes.Z)
            {
                //IO.Point(p);
                p = VectMath.RotateByAngle(p, VectMath.Cross(Axes.Z, Camera1.NormalAxis), 180 * (VectMath.AngleBetween(new _Point(0, 0, 1), Camera1.NormalAxis)) / Math.PI);
                //IO.Point(p);
            }
            //if( Camera1.VerticalAxis != Axes.Y)
            // {
            //     p = VectMath.RotateByAngle(p, Camera1.NormalAxis, 180*(VectMath.AngleBetween(new _Point(0, 1, 0), Camera1.VerticalAxis))/Math.PI);
            // }
            if (p.z <= 0)
            {
                return(new Point(0, 0));
            }
            int Xcoord = Convert.ToInt32((p.x * Globals.BMSize.Width / 2) / (p.z * Math.Tan(45))) + Globals.BMSize.Width / 2;
            int Ycoord = Convert.ToInt32((-p.y * Globals.BMSize.Height / 2) / (p.z * Math.Tan(45))) + Globals.BMSize.Height / 2;

            p.PF = new PointF(Xcoord, Ycoord);

            return(new Point(Xcoord, Ycoord));
        }
Exemplo n.º 3
0
 public _Point CalculateNormal()
 {
     return(VectMath.Cross(VectMath.Subtract(Points[1], Points[0]), VectMath.Subtract(Points[2], Points[0])));
 }