Beispiel #1
0
 /// <summary>sets this to multivector value.
 /// </summary>
 public void Set(mv src)
 {
     AllocateGroups(src.gu());
     if (m_c[0] != null)
     {
         c3ga.Copy_1(m_c[0], src.m_c[0]);
     }
     if (m_c[1] != null)
     {
         c3ga.Copy_5(m_c[1], src.m_c[1]);
     }
     if (m_c[2] != null)
     {
         c3ga.Copy_10(m_c[2], src.m_c[2]);
     }
     if (m_c[3] != null)
     {
         c3ga.Copy_10(m_c[3], src.m_c[3]);
     }
     if (m_c[4] != null)
     {
         c3ga.Copy_5(m_c[4], src.m_c[4]);
     }
     if (m_c[5] != null)
     {
         c3ga.Copy_1(m_c[5], src.m_c[5]);
     }
 }
Beispiel #2
0
 public void Set(mv src)
 {
     if (src.c()[2] != null)
     {
         float[] ptr = src.c()[2];
         m_c[0] = ptr[0];
         m_c[1] = ptr[1];
         m_c[2] = ptr[2];
         m_c[3] = ptr[3];
         m_c[4] = ptr[4];
         m_c[5] = ptr[5];
         m_c[6] = ptr[6];
         m_c[7] = ptr[7];
         m_c[8] = ptr[8];
         m_c[9] = ptr[9];
     }
     else
     {
         m_c[0] = 0.0f;
         m_c[1] = 0.0f;
         m_c[2] = 0.0f;
         m_c[3] = 0.0f;
         m_c[4] = 0.0f;
         m_c[5] = 0.0f;
         m_c[6] = 0.0f;
         m_c[7] = 0.0f;
         m_c[8] = 0.0f;
         m_c[9] = 0.0f;
     }
 }
Beispiel #3
0
 public void Set(mv src)
 {
     if (src.c()[1] != null)
     {
         float[] ptr = src.c()[1];
         m_c[0] = ptr[1];
         m_c[1] = ptr[2];
         m_c[2] = ptr[3];
     }
     else
     {
         m_c[0] = 0.0f;
         m_c[1] = 0.0f;
         m_c[2] = 0.0f;
     }
 }
Beispiel #4
0
 public void Set(mv src)
 {
     if (src.c()[2] != null)
     {
         float[] ptr = src.c()[2];
         m_c[0] = ptr[7];
         m_c[1] = ptr[8];
         m_c[2] = ptr[9];
         m_c[3] = ptr[6];
     }
     else
     {
         m_c[0] = 0.0f;
         m_c[1] = 0.0f;
         m_c[2] = 0.0f;
         m_c[3] = 0.0f;
     }
 }
Beispiel #5
0
 /// <summary>Computes exponential of mv up to 12th term.
 /// 
 /// </summary>
 public static mv exp(mv x)
 {
     return exp(x, 12);
 }
Beispiel #6
0
 /// <summary>
 /// Constructs a new circle from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public circle(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #7
0
 /// <summary>
 /// Constructs a new circle from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public circle(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #8
0
 /// <summary>
 /// Constructs a new normalizedPoint from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public normalizedPoint(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #9
0
 /// <summary>sets this to multivector value.
 /// </summary>
 public void Set(mv src)
 {
     AllocateGroups(src.gu());
     if (m_c[0] != null) {
     c3ga.Copy_1(m_c[0], src.m_c[0]);
     }
     if (m_c[1] != null) {
     c3ga.Copy_5(m_c[1], src.m_c[1]);
     }
     if (m_c[2] != null) {
     c3ga.Copy_10(m_c[2], src.m_c[2]);
     }
     if (m_c[3] != null) {
     c3ga.Copy_10(m_c[3], src.m_c[3]);
     }
     if (m_c[4] != null) {
     c3ga.Copy_5(m_c[4], src.m_c[4]);
     }
     if (m_c[5] != null) {
     c3ga.Copy_1(m_c[5], src.m_c[5]);
     }
 }
Beispiel #10
0
 /// <summary>
 /// Constructs a new pointPair from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public pointPair(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #11
0
 public void Set(mv src)
 {
 }
Beispiel #12
0
 /// <summary>
 /// Constructs a new line from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public line(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #13
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 public mv(mv A)
 {
     Set(A);
 }
Beispiel #14
0
 /// <summary>
 /// Constructs a new dualLine from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public dualLine(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #15
0
 /// <summary>
 /// Constructs a new plane from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public plane(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #16
0
 /// <summary>
 /// Constructs a new line from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public line(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #17
0
 /// <summary>
 /// Constructs a new flatPoint from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public flatPoint(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #18
0
 public void Set(mv src)
 {
     if (src.c()[2] != null) {
     float[] ptr = src.c()[2];
     m_c[0] = ptr[7];
     m_c[1] = ptr[8];
     m_c[2] = ptr[9];
     m_c[3] = ptr[6];
     }
     else {
     m_c[0] = 0.0f;
     m_c[1] = 0.0f;
     m_c[2] = 0.0f;
     m_c[3] = 0.0f;
     }
 }
Beispiel #19
0
        /// <summary>Computes exponential of mv.
        /// 
        /// </summary>
        public static mv exp(mv x, int order)
        {
            { // First try special cases: check if (x * x) is scalar
            mv xSquared = gp(x, x);
            float s_xSquared = xSquared.get_scalar();
            if ((norm2_returns_scalar(xSquared) - s_xSquared * s_xSquared) < 1E-06f) {
            // OK (x * x == ~scalar), so use special cases:
            if (s_xSquared < 0.0f) {
                float a = (float)Math.Sqrt(-s_xSquared);
                return sas(x, (float)Math.Sin(a) / a, (float)Math.Cos(a));
            }
            else if (s_xSquared > 0.0f) {
                float a = (float)Math.Sqrt(s_xSquared);
                return sas(x, (float)Math.Sinh(a) / a, (float)Math.Cosh(a));
            }
            else {
                return sas(x, 1.0f, 1.0f);
            }
            }
            }

            // else do general series eval . . .

            // result = 1 + ....
            mv result = new mv(1.0f);
            if (order == 0) return result;

            // find scale (power of 2) such that its norm is < 1
            ulong maxC = (ulong)x.LargestCoordinate();
            int scale = 1;
            if (maxC > 1) scale <<= 1;
            while (maxC != 0)
            {
            maxC >>= 1;
            scale <<= 1;
            }

            // scale
            mv xScaled = gp(x, 1.0f / (float)scale);

            // taylor series approximation
            mv xPow1 = new mv(1.0f);
            for (int i = 1; i <= order; i++) {
            mv xPow2 = gp(xPow1, xScaled);
            xPow1 = gp(xPow2, 1.0f / (float)i);

            result = add(result, xPow1); // result2 = result1 + xPow1
            }

            // undo scaling
            while (scale > 1)
            {
            result = gp(result, result);
            scale >>= 1;
            }

            return result;
        }
Beispiel #20
0
        private mv Parse()
        {
            int token;
            bool firstLoop = true;

            // get the first token
            token = getNextToken();

            while (true) {
                // reset for next basis blade
                BasisBlade bb = new BasisBlade();
                bool beDone = false; // basis element done

                if (token == T_END_OF_STRING) break;

                int cnt = 0;
                while ((token == T_PLUS) || (token == T_MINUS)) { // accept all +-
                    cnt++;
                    startIdx = endIdx+1;
                    if (token == T_MINUS) bb.multiply(-1.0f); // -
                    token = getNextToken();
                }

                // require at least one +- if this is not the first term:
                if ((!firstLoop) && (cnt == 0)) {
                    throw GetException("Expected '+' or '-'");
                }

                if ((token == T_NUMBER) ||
                    ((token >= T_FIRST_BASIS_VECTOR) && (token <= T_LAST_BASIS_VECTOR))) // must be number or basis vector
                {
                    if (token == T_NUMBER) {
                        { // multiply scale with value of number
                            try {
                                bb.multiply((float)Double.Parse(substring(startIdx, endIdx)));
                            } catch (Exception ) {
                                throw GetException("Cannot parse number");
                            }
                        }
                        startIdx = endIdx+1;

                        // * or ^ ?
                        token = getNextToken();
                        if ((token == T_WEDGE) || (token == T_MUL)) {
                            startIdx = endIdx+1;

                            // must find basis vector
                            token = getNextToken();
                        }
                        else { // just a single scalar is OK
                            startIdx = endIdx+1;
                            beDone = true;
                        }

                    }

                    if (!beDone) {
                        if ((token >= T_FIRST_BASIS_VECTOR) && (token <= T_LAST_BASIS_VECTOR)) {
                            int bvIdx = token - T_FIRST_BASIS_VECTOR;
                            bb.wedgeBasisVector(bvIdx);
                            startIdx = endIdx+1;
                        }
                        else {
                            throw GetException("Expected basis vector");
                        }
                    }

                    if (!beDone) {
                        // accept ^ basis vector as many times as it takes
                        while (true) {
                            // ^
                            token = getNextToken();
                            if (token != T_WEDGE) break;
                            startIdx = endIdx+1;

                            // basis vector
                            token = getNextToken();
                            if ((token >= T_FIRST_BASIS_VECTOR) && (token <= T_LAST_BASIS_VECTOR)) {
                                int bvIdx = token - T_FIRST_BASIS_VECTOR;
                                bb.wedgeBasisVector(bvIdx);
                                startIdx = endIdx+1;
                            }
                            else {
                                throw GetException("Expected basis vector");
                            }

                        }

                    }
                } // end of 'if number or bv'
                else if (token == T_BAD_CHARACTER) {
                    throw GetException("Bad character");
                }
                else if (token == T_BAD_NUMBER) {
                    throw GetException("Bad number");
                }
                else if (token == T_BAD_IDENTIFIER) {
                    throw GetException("Bad identifier");
                }
                else {
                    throw GetException("Unexpected token");
                }

                // add
                sum(bb);

                // remember that the first loop is done
                firstLoop = false;
            }

            mv result = new mv(GroupBitmap.GRADE_0 | GroupBitmap.GRADE_1 | GroupBitmap.GRADE_2 | GroupBitmap.GRADE_3 | GroupBitmap.GRADE_4 | GroupBitmap.GRADE_5 | 0,  coord);
            result.Compress(0.0f);
            return result;
        }
Beispiel #21
0
 /// <summary>
 /// Constructs a new pointPair from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public pointPair(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #22
0
 /// <summary>
 /// Constructs a new e1_t from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public e1_t(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #23
0
 /// <summary>
 /// Constructs a new vectorE3GA from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public vectorE3GA(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #24
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 public mv(mv A)
 {
     Set(A);
 }
Beispiel #25
0
 public void Set(mv src)
 {
 }
Beispiel #26
0
 public void Set(mv src)
 {
     if (src.c()[1] != null) {
     float[] ptr = src.c()[1];
     m_c[0] = ptr[1];
     m_c[1] = ptr[2];
     m_c[2] = ptr[3];
     }
     else {
     m_c[0] = 0.0f;
     m_c[1] = 0.0f;
     m_c[2] = 0.0f;
     }
 }
Beispiel #27
0
        private mv Parse()
        {
            int  token;
            bool firstLoop = true;

            // get the first token
            token = getNextToken();

            while (true)
            {
                // reset for next basis blade
                BasisBlade bb     = new BasisBlade();
                bool       beDone = false;           // basis element done

                if (token == T_END_OF_STRING)
                {
                    break;
                }

                int cnt = 0;
                while ((token == T_PLUS) || (token == T_MINUS))                   // accept all +-
                {
                    cnt++;
                    startIdx = endIdx + 1;
                    if (token == T_MINUS)
                    {
                        bb.multiply(-1.0f);                                       // -
                    }
                    token = getNextToken();
                }

                // require at least one +- if this is not the first term:
                if ((!firstLoop) && (cnt == 0))
                {
                    throw GetException("Expected '+' or '-'");
                }

                if ((token == T_NUMBER) ||
                    ((token >= T_FIRST_BASIS_VECTOR) && (token <= T_LAST_BASIS_VECTOR)))                     // must be number or basis vector
                {
                    if (token == T_NUMBER)
                    {
                        {                         // multiply scale with value of number
                            try {
                                bb.multiply((float)Double.Parse(substring(startIdx, endIdx)));
                            } catch (Exception) {
                                throw GetException("Cannot parse number");
                            }
                        }
                        startIdx = endIdx + 1;

                        // * or ^ ?
                        token = getNextToken();
                        if ((token == T_WEDGE) || (token == T_MUL))
                        {
                            startIdx = endIdx + 1;

                            // must find basis vector
                            token = getNextToken();
                        }
                        else                           // just a single scalar is OK
                        {
                            startIdx = endIdx + 1;
                            beDone   = true;
                        }
                    }

                    if (!beDone)
                    {
                        if ((token >= T_FIRST_BASIS_VECTOR) && (token <= T_LAST_BASIS_VECTOR))
                        {
                            int bvIdx = token - T_FIRST_BASIS_VECTOR;
                            bb.wedgeBasisVector(bvIdx);
                            startIdx = endIdx + 1;
                        }
                        else
                        {
                            throw GetException("Expected basis vector");
                        }
                    }

                    if (!beDone)
                    {
                        // accept ^ basis vector as many times as it takes
                        while (true)
                        {
                            // ^
                            token = getNextToken();
                            if (token != T_WEDGE)
                            {
                                break;
                            }
                            startIdx = endIdx + 1;

                            // basis vector
                            token = getNextToken();
                            if ((token >= T_FIRST_BASIS_VECTOR) && (token <= T_LAST_BASIS_VECTOR))
                            {
                                int bvIdx = token - T_FIRST_BASIS_VECTOR;
                                bb.wedgeBasisVector(bvIdx);
                                startIdx = endIdx + 1;
                            }
                            else
                            {
                                throw GetException("Expected basis vector");
                            }
                        }
                    }
                }                 // end of 'if number or bv'
                else if (token == T_BAD_CHARACTER)
                {
                    throw GetException("Bad character");
                }
                else if (token == T_BAD_NUMBER)
                {
                    throw GetException("Bad number");
                }
                else if (token == T_BAD_IDENTIFIER)
                {
                    throw GetException("Bad identifier");
                }
                else
                {
                    throw GetException("Unexpected token");
                }

                // add
                sum(bb);

                // remember that the first loop is done
                firstLoop = false;
            }


            mv result = new mv(GroupBitmap.GRADE_0 | GroupBitmap.GRADE_1 | GroupBitmap.GRADE_2 | GroupBitmap.GRADE_3 | GroupBitmap.GRADE_4 | GroupBitmap.GRADE_5 | 0, coord);

            result.Compress(0.0f);
            return(result);
        } // end of Parse()
Beispiel #28
0
 /// <summary>
 /// Constructs a new normalizedPoint from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public normalizedPoint(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #29
0
 /// <summary>
 /// Constructs a new vectorE3GA from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public vectorE3GA(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #30
0
 /// <summary>
 /// Constructs a new ni_t from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public ni_t(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #31
0
 /// <summary>
 /// Constructs a new dualLine from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public dualLine(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #32
0
 /// <summary>
 /// Constructs a new flatPoint from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public flatPoint(mv A /*, int filler */)
 {
     Set(A);
 }
Beispiel #33
0
 /// <summary>internal conversion function
 /// </summary>
 public static float norm_returns_scalar(mv a)
 {
     return norm(a);
 }
Beispiel #34
0
 public void Set(mv src)
 {
     if (src.c()[3] != null) {
     float[] ptr = src.c()[3];
     m_c[0] = ptr[0];
     m_c[1] = ptr[1];
     m_c[2] = ptr[2];
     m_c[3] = ptr[3];
     m_c[4] = ptr[4];
     m_c[5] = ptr[5];
     m_c[6] = ptr[6];
     m_c[7] = ptr[7];
     m_c[8] = ptr[8];
     m_c[9] = ptr[9];
     }
     else {
     m_c[0] = 0.0f;
     m_c[1] = 0.0f;
     m_c[2] = 0.0f;
     m_c[3] = 0.0f;
     m_c[4] = 0.0f;
     m_c[5] = 0.0f;
     m_c[6] = 0.0f;
     m_c[7] = 0.0f;
     m_c[8] = 0.0f;
     m_c[9] = 0.0f;
     }
 }
Beispiel #35
0
 /// <summary>
 /// Constructs a new plane from mv.
 /// </summary>
 /// <param name="A">The value to copy. Coordinates that cannot be represented are silently dropped. </param>
 public plane(mv A /*, int filler */)
 {
     Set(A);
 }