Ejemplo n.º 1
0
        /*
        This small example creates a line and a plane from points.
        It then computes the intersection point of the line and the plane.

        In this step, all GA variables are stored in specialized multivector types,
        such as 'line', 'plane' and 'flatPoint'.
        */
        static void Main(string[] args)
        {
            // get five points
            normalizedPoint linePt1 = c3ga.cgaPoint(1.0f, 0.0f, 0.0f);
            normalizedPoint linePt2 = c3ga.cgaPoint(1.0f, 1.0f, 0.0f);
            normalizedPoint planePt1 = c3ga.cgaPoint(1.0f, 2.0f, 0.0f);
            normalizedPoint planePt2 = c3ga.cgaPoint(1.0f, 2.0f, 1.0f);
            normalizedPoint planePt3 = c3ga.cgaPoint(0.0f, 2.0f, 1.0f);

            // output text the can be copy-pasted into GAViewer
            Console.WriteLine("linePt1 = " + linePt1 + ",");
            Console.WriteLine("linePt2 = " + linePt2 + ",");
            Console.WriteLine("planePt1 = " + planePt1 + ",");
            Console.WriteLine("planePt2 = " + planePt2 + ",");
            Console.WriteLine("planePt3 = " + planePt3 + ",");

            // create line and plane out of points
            line L = new line((mv)linePt1 ^ (mv)linePt2 ^ (mv)c3ga.ni);
            //line L = new line(c3ga.op(linePt1, c3ga.op(linePt2, c3ga.ni))); // alternative, no explicit conversion required

            plane P = new plane((mv)planePt1 ^ (mv)planePt2 ^ (mv)planePt3 ^ (mv)c3ga.ni);
            //plane P = new plane(c3ga.op(planePt1, c3ga.op(planePt2, c3ga.op(planePt3, c3ga.ni)))); // alternative, no explicit conversion required

            // output text the can be copy-pasted into GAViewer
            Console.WriteLine("L = " + L + ",");
            Console.WriteLine("P = " + P + ",");

            // compute intersection of line and plane
            flatPoint intersection = new flatPoint(c3ga.lc(c3ga.dual(L), P));

            Console.WriteLine("intersection = " + intersection + ",");
        }
Ejemplo n.º 2
0
 public void Set(plane a)
 {
     m_c[0] = a.m_c[0];
     m_c[1] = a.m_c[1];
     m_c[2] = a.m_c[2];
     m_c[3] = a.m_c[3];
 }
Ejemplo n.º 3
0
        /// <summary>sets this to plane value.
        /// </summary>
        public void Set(plane src)
        {
            AllocateGroups(GroupBitmap.GROUP_4);
            float[] ptr;

            ptr    = m_c[4];
            ptr[0] = 0.0f;
            ptr[1] = src.m_c[3];
            ptr[2] = src.m_c[2];
            ptr[3] = src.m_c[1];
            ptr[4] = src.m_c[0];
        }
Ejemplo n.º 4
0
        /*
        This small example creates a line and a plane from points.
        It then computes the intersection point of the line and the plane.

        In this step, the 'reportUsage' functionality is used to extract what
        specialized functions and types are missing.
        */
        static void Main(string[] args)
        {
            // get five points
            normalizedPoint linePt1 = c3ga.cgaPoint(1.0f, 0.0f, 0.0f);
            normalizedPoint linePt2 = c3ga.cgaPoint(1.0f, 1.0f, 0.0f);
            normalizedPoint planePt1 = c3ga.cgaPoint(1.0f, 2.0f, 0.0f);
            normalizedPoint planePt2 = c3ga.cgaPoint(1.0f, 2.0f, 1.0f);
            normalizedPoint planePt3 = c3ga.cgaPoint(0.0f, 2.0f, 1.0f);

            // output text the can be copy-pasted into GAViewer
            Console.WriteLine("linePt1 = " + linePt1 + ",");
            Console.WriteLine("linePt2 = " + linePt2 + ",");
            Console.WriteLine("planePt1 = " + planePt1 + ",");
            Console.WriteLine("planePt2 = " + planePt2 + ",");
            Console.WriteLine("planePt3 = " + planePt3 + ",");

            // create line and plane out of points
            //line L = new line(linePt1 ^ (linePt2 ^ c3ga.ni));
            line L = new line(c3ga.op(linePt1, c3ga.op(linePt2, c3ga.ni))); // alternative, no explicit conversion required

            //plane P = new plane(planePt1 ^ (planePt2 ^ (planePt3 ^ c3ga.ni)));
            plane P = new plane(c3ga.op(planePt1, c3ga.op(planePt2, c3ga.op(planePt3, c3ga.ni)))); // alternative, no explicit conversion required

            // output text the can be copy-pasted into GAViewer
            Console.WriteLine("L = " + L + ",");
            Console.WriteLine("P = " + P + ",");

            // compute intersection of line and plane
            flatPoint intersection = new flatPoint(c3ga.lc(c3ga.dual(L), P));

            Console.WriteLine("intersection = " + intersection + ",");

            // output what functions could be optimized
            bool includeCount = true;
            Console.Write(ReportUsage.GetReport(includeCount));
        }
Ejemplo n.º 5
0
Archivo: mv.cs Proyecto: Sciumo/gaigen
        /// <summary>sets this to plane value.
        /// </summary>
        public void Set(plane src)
        {
            AllocateGroups(GroupBitmap.GROUP_4);
            float[] ptr;

            ptr = m_c[4];
            ptr[0] = 0.0f;
            ptr[1] = src.m_c[3];
            ptr[2] = src.m_c[2];
            ptr[3] = src.m_c[1];
            ptr[4] = src.m_c[0];
        }
Ejemplo n.º 6
0
Archivo: mv.cs Proyecto: Sciumo/gaigen
 /// <summary>
 /// Converts a plane to a mv.
 /// </summary>
 public mv(plane A)
 {
     Set(A);
 }
Ejemplo n.º 7
0
 /// <summary>shortcut to c3ga.lc(this, b)
 /// </summary>
 public pointPair lc(plane b)
 {
     return c3ga.lc(this, b);
 }
Ejemplo n.º 8
0
 /// <summary>shortcut to c3ga.lc(this, b)
 /// </summary>
 public flatPoint lc(plane b)
 {
     return(c3ga.lc(this, b));
 }
Ejemplo n.º 9
0
 /// <summary>shortcut to c3ga.lc(this, b)
 /// </summary>
 public pointPair lc(plane b)
 {
     return(c3ga.lc(this, b));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Converts a plane to a mv.
 /// </summary>
 public mv(plane A)
 {
     Set(A);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 public plane(plane A)
 {
     Set(A);
 }
Ejemplo n.º 12
0
 public void Set(plane a)
 {
     m_c[0] = a.m_c[0];
     m_c[1] = a.m_c[1];
     m_c[2] = a.m_c[2];
     m_c[3] = a.m_c[3];
 }
Ejemplo n.º 13
0
 /// <summary>Returns left contraction of pointPair and plane.
 /// </summary>
 public static pointPair lc(pointPair a, plane b)
 {
     return new pointPair(pointPair.coord_noe1_noe2_e1e2_noe3_e1e3_e2e3_noni_e1ni_e2ni_e3ni,
     (-a.m_c[1]*b.m_c[3]-a.m_c[3]*b.m_c[2]), // no_e1
     (a.m_c[0]*b.m_c[3]-a.m_c[3]*b.m_c[1]), // no_e2
     (-a.m_c[3]*b.m_c[0]+a.m_c[6]*b.m_c[3]), // e1_e2
     (a.m_c[0]*b.m_c[2]+a.m_c[1]*b.m_c[1]), // no_e3
     (a.m_c[1]*b.m_c[0]+a.m_c[6]*b.m_c[2]), // e1_e3
     (-a.m_c[0]*b.m_c[0]+a.m_c[6]*b.m_c[1]), // e2_e3
     (-a.m_c[2]*b.m_c[3]-a.m_c[4]*b.m_c[2]-a.m_c[5]*b.m_c[1]), // no_ni
     (-a.m_c[5]*b.m_c[0]+a.m_c[8]*b.m_c[3]+a.m_c[9]*b.m_c[2]), // e1_ni
     (a.m_c[4]*b.m_c[0]-a.m_c[7]*b.m_c[3]+a.m_c[9]*b.m_c[1]), // e2_ni
     (-a.m_c[2]*b.m_c[0]-a.m_c[7]*b.m_c[2]-a.m_c[8]*b.m_c[1]) // e3_ni
     );
 }
Ejemplo n.º 14
0
 /// <summary>Returns left contraction of dualLine and plane.
 /// </summary>
 public static flatPoint lc(dualLine a, plane b)
 {
     return new flatPoint(flatPoint.coord_e1ni_e2ni_e3ni_noni,
     (-a.m_c[2]*b.m_c[0]+a.m_c[4]*b.m_c[3]+a.m_c[5]*b.m_c[2]), // e1_ni
     (a.m_c[1]*b.m_c[0]-a.m_c[3]*b.m_c[3]+a.m_c[5]*b.m_c[1]), // e2_ni
     (-a.m_c[0]*b.m_c[0]-a.m_c[3]*b.m_c[2]-a.m_c[4]*b.m_c[1]), // e3_ni
     (-a.m_c[0]*b.m_c[3]-a.m_c[1]*b.m_c[2]-a.m_c[2]*b.m_c[1]) // no_ni
     );
 }
Ejemplo n.º 15
0
 /// <summary>shortcut to c3ga.lc(this, b)
 /// </summary>
 public flatPoint lc(plane b)
 {
     return c3ga.lc(this, b);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 public plane(plane A)
 {
     Set(A);
 }