Ejemplo n.º 1
0
 public static AffinePoint Zoom(this AffinePoint p, AffineZoom Zoom)
 {
     return(new AffinePoint
     {
         X = p.X * Zoom.X,
         Y = p.Y * Zoom.Y,
         Z = p.Z * Zoom.Z,
         Tag = p.Tag
     });
 }
Ejemplo n.º 2
0
        public static double GetYawn(this AffinePoint p)
        {
            var x = p.X;
            var y = p.Z;

            const double _180 = System.Math.PI;
            const double _90  = System.Math.PI / 2;
            const double _270 = System.Math.PI * 3 / 2;

            if (x == 0)
            {
                if (y < 0)
                {
                    return(_270);
                }
                else if (y == 0)
                {
                    return(0);
                }
                else
                {
                    return(_90);
                }
            }

            if (y == 0)
            {
                if (x < 0)
                {
                    return(_180);
                }
                else
                {
                    return(0);
                }
            }

            var a = System.Math.Atan(y / x);

            if (x < 0)
            {
                a += _180;
            }
            else if (y < 0)
            {
                a += System.Math.PI * 2;
            }


            return(a);
        }
Ejemplo n.º 3
0
        public static AffinePoint RotateXZ(this AffinePoint p, double Rotation)
        {
            // X,Z
            var r = new AffinePoint {
                X = p.X, Y = p.Z
            }.GetRotation() + Rotation;
            var z = new AffinePoint {
                X = p.X, Y = p.Z
            }.GetLength();

            var Z = Math.Sin(r) * z;
            var X = Math.Cos(r) * z;
            var Y = p.Y;

            return(new AffinePoint {
                X = X, Y = Y, Z = Z, Tag = p.Tag
            });
        }
Ejemplo n.º 4
0
 public static double GetLength(this AffinePoint p)
 {
     return(Math.Sqrt(p.X * p.X + p.Y * p.Y));
 }
Ejemplo n.º 5
0
 public static double GetYawnLength(this AffinePoint p)
 {
     return(Math.Sqrt(p.X * p.X + p.Z * p.Z));
 }
Ejemplo n.º 6
0
 public static AffinePoint Rotate(this AffinePoint p, AffineRotation Rotation)
 {
     return(p.RotateXY(Rotation.XY).RotateYZ(Rotation.XZ).RotateXZ(Rotation.XZ));
 }
Ejemplo n.º 7
0
 public void Add(AffinePoint p)
 {
     Points.Add(p);
 }
Ejemplo n.º 8
0
 public void Add(AffinePoint p)
 {
     Points.Add(p);
 }
        private void AddCubeFace18(
       AffineMesh a, string t, AffinePoint A, AffinePoint B, AffinePoint C, AffinePoint D)
        {
            var v1 =
               new AffineVertex
               {
                   A = A,
                   B = B,
                   C = C,

                   Element = new Avalon.Images._18
                   {
                       Width = 100,
                       Height = 100,
                   }.AttachTo(AffineContent),
                   ElementWidth = 100,
                   ElementHeight = 100
               };

            //var t1 = new TextBox { Text = t, Foreground = Brushes.Blue }.AttachTo(InfoContent);

            //v1.Tag = new Action<AffineVertex>(
            //    k =>
            //    {
            //        t1.Text = t + " " + Convert.ToInt32(k.Center.Z);
            //        t1.MoveTo(k.Center.X + DefaultWidth / 2, k.Center.Y + DefaultHeight / 2);

            //    }
            //);

            a.Add(v1);

            //var v2 =
            //    new AffineVertex
            //    {
            //        A = D,
            //        B = C,
            //        C = B,

            //        Element = new Avalon.Images._18.AffineTriangle2
            //        {
            //            Width = 100,
            //            Height = 100,
            //        }.AttachTo(AffineContent),
            //        ElementWidth = 100,
            //        ElementHeight = 100
            //    };

            ////v2.Element.Opacity = 0.5;

            ////var t2 = new TextBox { Text = t }.AttachTo(InfoContent);

            ////v2.Tag = new Action<AffineVertex>(
            ////    k =>
            ////    {
            ////        t2.Text = t + " " + Convert.ToInt32(k.Center.Z);
            ////        t2.MoveTo(k.Center.X + DefaultWidth / 2, k.Center.Y + DefaultHeight / 2);

            ////    }
            ////);

            //a.Add(v2);

        }
        private void AddCube(AffineMesh a, AffinePoint Offset = null)
        {

            // front
            AddCubeFace(a, "front",
               new AffinePoint(-100, -100, 100) + Offset,
               new AffinePoint(100, -100, 100) + Offset,
               new AffinePoint(-100, 100, 100) + Offset,
               new AffinePoint(100, 100, 100) + Offset
           );

            // right
            AddCubeFace18(a, "right",
               new AffinePoint(100, -100, 100) + Offset,
               new AffinePoint(100, -100, -100) + Offset,
               new AffinePoint(100, 100, 100) + Offset,
               new AffinePoint(100, 100, -100) + Offset
           );

            // left
            AddCubeFace18(a, "left",
               new AffinePoint(-100, -100, 100) + Offset,
               new AffinePoint(-100, -100, -100) + Offset,
               new AffinePoint(-100, 100, 100) + Offset,
               new AffinePoint(-100, 100, -100) + Offset
           );

            // back
            AddCubeFace18(a, "back",
               new AffinePoint(-100, -100, -100) + Offset,
               new AffinePoint(100, -100, -100) + Offset,
               new AffinePoint(-100, 100, -100) + Offset,
               new AffinePoint(100, 100, -100) + Offset
           );

            // top
            AddCubeFace18(a, "top",
               new AffinePoint(-100, 100, -100) + Offset,
               new AffinePoint(100, 100, -100) + Offset,
               new AffinePoint(-100, 100, 100) + Offset,
               new AffinePoint(100, 100, 100) + Offset
           );

            // bottom
            AddCubeFace18(a, "bottom",
                new AffinePoint(-100, -100, -100) + Offset,
                new AffinePoint(100, -100, -100) + Offset,
                new AffinePoint(-100, -100, 100) + Offset,
                new AffinePoint(100, -100, 100) + Offset
            );
        }