Example #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 + ",");
        }
Example #2
0
 public void Set(flatPoint 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];
 }
Example #3
0
        /// <summary>sets this to flatPoint value.
        /// </summary>
        public void Set(flatPoint src)
        {
            AllocateGroups(GroupBitmap.GROUP_2);
            float[] ptr;

            ptr    = m_c[2];
            ptr[0] = ptr[1] = ptr[2] = ptr[3] = ptr[4] = ptr[5] = 0.0f;
            ptr[6] = src.m_c[3];
            ptr[7] = src.m_c[0];
            ptr[8] = src.m_c[1];
            ptr[9] = src.m_c[2];
        }
Example #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));
        }
Example #5
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 public flatPoint(flatPoint A)
 {
     Set(A);
 }
Example #6
0
File: mv.cs Project: Sciumo/gaigen
        /// <summary>sets this to flatPoint value.
        /// </summary>
        public void Set(flatPoint src)
        {
            AllocateGroups(GroupBitmap.GROUP_2);
            float[] ptr;

            ptr = m_c[2];
            ptr[0] = ptr[1] = ptr[2] = ptr[3] = ptr[4] = ptr[5] = 0.0f;
            ptr[6] = src.m_c[3];
            ptr[7] = src.m_c[0];
            ptr[8] = src.m_c[1];
            ptr[9] = src.m_c[2];
        }
Example #7
0
File: mv.cs Project: Sciumo/gaigen
 /// <summary>
 /// Converts a flatPoint to a mv.
 /// </summary>
 public mv(flatPoint A)
 {
     Set(A);
 }
Example #8
0
 /// <summary>shortcut to c3ga.op(this, b)
 /// </summary>
 public line op(flatPoint b)
 {
     return(c3ga.op(this, b));
 }
Example #9
0
 /// <summary>
 /// Converts a flatPoint to a mv.
 /// </summary>
 public mv(flatPoint A)
 {
     Set(A);
 }
Example #10
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 public flatPoint(flatPoint A)
 {
     Set(A);
 }
Example #11
0
 public void Set(flatPoint 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];
 }
Example #12
0
        /// <summary>Returns conformal point.
        /// </summary>
        public static normalizedPoint cgaPoint(flatPoint a)
        {
            vectorE3GA _v_ = new vectorE3GA();
            _v_.m_c[0] = a.m_c[0]/((a.m_c[3]));
            _v_.m_c[1] = a.m_c[1]/((a.m_c[3]));
            _v_.m_c[2] = a.m_c[2]/((a.m_c[3]));

            return new normalizedPoint(normalizedPoint.coord_e1_e2_e3_ni,
            _v_.m_c[0], // e1
            _v_.m_c[1], // e2
            _v_.m_c[2], // e3
            (0.5f*_v_.m_c[0]*_v_.m_c[0]+0.5f*_v_.m_c[1]*_v_.m_c[1]+0.5f*_v_.m_c[2]*_v_.m_c[2]) // ni
            );
        }
Example #13
0
 /// <summary>Returns outer product of normalizedPoint and flatPoint.
 /// </summary>
 public static line op(normalizedPoint a, flatPoint b)
 {
     return new line(line.coord_e1e2ni_e1e3ni_e2e3ni_e1noni_e2noni_e3noni,
     (a.m_c[0]*b.m_c[1]-a.m_c[1]*b.m_c[0]), // e1_e2_ni
     (a.m_c[0]*b.m_c[2]-a.m_c[2]*b.m_c[0]), // e1_e3_ni
     (a.m_c[1]*b.m_c[2]-a.m_c[2]*b.m_c[1]), // e2_e3_ni
     -(-a.m_c[0]*b.m_c[3]+b.m_c[0]), // e1_no_ni
     -(-a.m_c[1]*b.m_c[3]+b.m_c[1]), // e2_no_ni
     -(-a.m_c[2]*b.m_c[3]+b.m_c[2]) // e3_no_ni
     );
 }
Example #14
0
 /// <summary>shortcut to c3ga.op(this, b)
 /// </summary>
 public line op(flatPoint b)
 {
     return c3ga.op(this, b);
 }