コード例 #1
0
ファイル: Program.cs プロジェクト: Sciumo/gaigen
        /*
        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 + ",");
        }
コード例 #2
0
 public void Set(line 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];
     m_c[4] = a.m_c[4];
     m_c[5] = a.m_c[5];
 }
コード例 #3
0
        /// <summary>sets this to line value.
        /// </summary>
        public void Set(line src)
        {
            AllocateGroups(GroupBitmap.GROUP_3);
            float[] ptr;

            ptr    = m_c[3];
            ptr[0] = ptr[1] = ptr[2] = ptr[3] = 0.0f;
            ptr[4] = -src.m_c[3];
            ptr[5] = -src.m_c[4];
            ptr[6] = src.m_c[0];
            ptr[7] = -src.m_c[5];
            ptr[8] = src.m_c[1];
            ptr[9] = src.m_c[2];
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: Sciumo/gaigen
        /*
        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));
        }
コード例 #5
0
ファイル: mv.cs プロジェクト: Sciumo/gaigen
        /// <summary>sets this to line value.
        /// </summary>
        public void Set(line src)
        {
            AllocateGroups(GroupBitmap.GROUP_3);
            float[] ptr;

            ptr = m_c[3];
            ptr[0] = ptr[1] = ptr[2] = ptr[3] = 0.0f;
            ptr[4] = -src.m_c[3];
            ptr[5] = -src.m_c[4];
            ptr[6] = src.m_c[0];
            ptr[7] = -src.m_c[5];
            ptr[8] = src.m_c[1];
            ptr[9] = src.m_c[2];
        }
コード例 #6
0
ファイル: mv.cs プロジェクト: Sciumo/gaigen
 /// <summary>
 /// Converts a line to a mv.
 /// </summary>
 public mv(line A)
 {
     Set(A);
 }
コード例 #7
0
ファイル: line.cs プロジェクト: Sciumo/gaigen
 /// <summary>
 /// Copy constructor.
 /// </summary>
 public line(line A)
 {
     Set(A);
 }
コード例 #8
0
ファイル: line.cs プロジェクト: Sciumo/gaigen
 public void Set(line 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];
     m_c[4] = a.m_c[4];
     m_c[5] = a.m_c[5];
 }
コード例 #9
0
 /// <summary>shortcut to c3ga.op(this, b)
 /// </summary>
 public plane op(line b)
 {
     return(c3ga.op(this, b));
 }
コード例 #10
0
 /// <summary>
 /// Converts a line to a mv.
 /// </summary>
 public mv(line A)
 {
     Set(A);
 }
コード例 #11
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 public line(line A)
 {
     Set(A);
 }
コード例 #12
0
ファイル: c3ga.cs プロジェクト: Sciumo/gaigen
 /// <summary>Returns dual of line using default metric.
 /// </summary>
 public static dualLine dual(line a)
 {
     return new dualLine(dualLine.coord_e1e2_e1e3_e2e3_e1ni_e2ni_e3ni,
     a.m_c[5], // e1_e2
     -a.m_c[4], // e1_e3
     a.m_c[3], // e2_e3
     -a.m_c[2], // e1_ni
     a.m_c[1], // e2_ni
     -a.m_c[0] // e3_ni
     );
 }
コード例 #13
0
ファイル: c3ga.cs プロジェクト: Sciumo/gaigen
 /// <summary>Returns outer product of normalizedPoint and line.
 /// </summary>
 public static plane op(normalizedPoint a, line b)
 {
     return new plane(plane.coord_e1e2e3ni_noe2e3ni_noe1e3ni_noe1e2ni,
     (a.m_c[0]*b.m_c[2]-a.m_c[1]*b.m_c[1]+a.m_c[2]*b.m_c[0]), // e1_e2_e3_ni
     (a.m_c[1]*b.m_c[5]-a.m_c[2]*b.m_c[4]+b.m_c[2]), // no_e2_e3_ni
     (a.m_c[0]*b.m_c[5]-a.m_c[2]*b.m_c[3]+b.m_c[1]), // no_e1_e3_ni
     (a.m_c[0]*b.m_c[4]-a.m_c[1]*b.m_c[3]+b.m_c[0]) // no_e1_e2_ni
     );
 }
コード例 #14
0
ファイル: normalizedPoint.cs プロジェクト: Sciumo/gaigen
 /// <summary>shortcut to c3ga.op(this, b)
 /// </summary>
 public plane op(line b)
 {
     return c3ga.op(this, b);
 }