Наследование: ITransform
Пример #1
0
 public Isometry(Isometry i)
 {
     Mobius = i.Mobius;
     if (i.Reflection != null)
     {
         Reflection = i.Reflection.Clone();
     }
 }
Пример #2
0
        /// <summary>
        /// Returns an isometry which represents a reflection across the x axis.
        /// </summary>
        public static Isometry ReflectX()
        {
            Isometry i          = new Isometry();
            Circle   reflection = new Circle(new Vector3D(), new Vector3D(1, 0));

            i.Reflection = reflection;
            return(i);
        }
Пример #3
0
        /// <summary>
        /// Simple helper to transform an array of vertices using an isometry.
        /// Warning! Allocates a new array.
        /// </summary>
        public static Vector3D[] TransformVertices(Vector3D[] vertices, Isometry isometry)
        {
            List <Vector3D> result = new List <Vector3D>();

            for (int i = 0; i < vertices.Length; i++)
            {
                Vector3D transformed = isometry.Apply(vertices[i]);
                result.Add(transformed);
            }
            return(result.ToArray());
        }
Пример #4
0
        /// <summary>
        /// Composition operator.
        /// </summary>>
        public static Isometry operator *(Isometry i1, Isometry i2)
        {
            // ZZZ - Probably a better way.
            // We'll just apply both isometries to a canonical set of points,
            // Then calc which isometry makes that.

            Complex p1 = new Complex(1, 0);
            Complex p2 = new Complex(-1, 0);
            Complex p3 = new Complex(0, 1);
            Complex w1 = p1, w2 = p2, w3 = p3;

            // Compose (apply in reverse order).
            w1 = i2.Apply(w1);
            w2 = i2.Apply(w2);
            w3 = i2.Apply(w3);
            w1 = i1.Apply(w1);
            w2 = i1.Apply(w2);
            w3 = i1.Apply(w3);

            Mobius m = new Mobius();

            m.MapPoints(p1, p2, p3, w1, w2, w3);

            Isometry result = new Isometry();

            result.Mobius = m;

            // Need to reflect at end?
            bool r1 = i1.Reflection != null;
            bool r2 = i2.Reflection != null;

            if (r1 ^ r2)                // One and only one reflection.
            {
                result.Reflection = new Circle(
                    Vector3D.FromComplex(w1),
                    Vector3D.FromComplex(w2),
                    Vector3D.FromComplex(w3));
            }

            return(result);
        }
Пример #5
0
 public void Transform( Isometry i )
 {
     Boundary.Transform( i );
     Drawn.Transform( i );
     VertexCircle.Transform( i );
 }
Пример #6
0
 public Tile()
 {
     Isometry = new Isometry();
     EdgeIncidences = new List<Tile>();
     VertexIndicences = new List<Tile>();
 }
Пример #7
0
        /// <summary>
        /// Composition operator.
        /// </summary>>
        public static Isometry operator *( Isometry i1, Isometry i2 )
        {
            // ZZZ - Probably a better way.
            // We'll just apply both isometries to a canonical set of points,
            // Then calc which isometry makes that.

            Complex p1 = new Complex( 1, 0 );
            Complex p2 = new Complex( -1, 0 );
            Complex p3 = new Complex( 0, 1 );
            Complex w1 = p1, w2 = p2, w3 = p3;

            // Compose (apply in reverse order).
            w1 = i2.Apply( w1 );
            w2 = i2.Apply( w2 );
            w3 = i2.Apply( w3 );
            w1 = i1.Apply( w1 );
            w2 = i1.Apply( w2 );
            w3 = i1.Apply( w3 );

            Mobius m = new Mobius();
            m.MapPoints( p1, p2, p3, w1, w2, w3 );

            Isometry result = new Isometry();
            result.Mobius = m;

            // Need to reflect at end?
            bool r1 = i1.Reflection != null;
            bool r2 = i2.Reflection != null;
            if( r1 ^ r2 )	// One and only one reflection.
            {
                result.Reflection = new Circle(
                    Vector3D.FromComplex( w1 ),
                    Vector3D.FromComplex( w2 ),
                    Vector3D.FromComplex( w3 ) );
            }

            return result;
        }
Пример #8
0
 public Isometry( Isometry i )
 {
     Mobius = i.Mobius;
     if( i.Reflection != null )
         Reflection = i.Reflection.Clone();
 }
Пример #9
0
 /// <summary>
 /// Simple helper to transform an array of vertices using an isometry.
 /// Warning! Allocates a new array.
 /// </summary>
 public static Vector3D[] TransformVertices( Vector3D[] vertices, Isometry isometry )
 {
     List<Vector3D> result = new List<Vector3D>();
     for( int i = 0; i < vertices.Length; i++ )
     {
         Vector3D transformed = isometry.Apply( vertices[i] );
         result.Add( transformed );
     }
     return result.ToArray();
 }
Пример #10
0
 /// <summary>
 /// Returns an isometry which represents a reflection across the x axis.
 /// </summary>
 public static Isometry ReflectX()
 {
     Isometry i = new Isometry();
     Circle reflection = new Circle( new Vector3D(), new Vector3D( 1, 0 ) );
     i.Reflection = reflection;
     return i;
 }