示例#1
0
        /// <summary>
        /// Transforms point p (p.w is presumed 1.0) by matrix m.
        /// Projective transform is performed. Perspective Division is performed.
        /// </summary>
        public static __ftype__ TransformPosProj(__nmtype__ m, __ftype__ p)
        {
            __ftype__ s = m.M10 * p + m.M11;

            s = 1 / s;
            return((TransformPos(m, p)) * s);
        }
示例#2
0
        /// <summary>
        /// Transforms point p (p.w is presumed 1.0) by matrix m.
        /// Projective transform is performed. Perspective Division is performed.
        /// </summary>
        public static __vmsub1type__ TransformPosProj(__nmtype__ m, __vmsub1type__ p)
        {
            __ftype__ s = (/*# mfields.Take(msub1).ForEach((fr, r) => { */ m.M__msub1____r__ * p.__fr__ /*#}, add);*/ + m.M__msub1____msub1__);

            s = 1 / s;
            return((TransformPos(m, p)) * s);
        }
示例#3
0
 /// <summary>
 /// Returns the minimal absolute distance between the components of
 /// the two matrices.
 /// </summary>
 public static __ftype__ DistanceMin(__nmtype__ a, __nmtype__ b)
 {
     return(Fun.Min(     /*# n.ForEach(i => { */
                Fun.Min( /*# m.ForEach(j => { */
                    Fun.Abs(b.M__i____j__ - a.M__i____j__) /*#
                                                            * }, comma); */) /*# }, comma); */));
 }
示例#4
0
 //# if (n == m) {
 /// <summary>
 /// Transforms direction vector v (v.w is presumed 0.0) by transposed version of matrix m.
 /// </summary>
 public static __vmsub1type__ TransposedTransformDir(__nmtype__ m, __vmsub1type__ v)
 {
     return(new __vmsub1type__(                                                          /*# msub1.ForEach(s => { */
                /*# mfields.Take(msub1).ForEach((fr, r) => { */ m.M__r____s__ * v.__fr__ /*# }, add); }, comma); */
                ));
 }
示例#5
0
 /// <summary>
 /// Transforms point p (p.w is presumed 1.0) by matrix m.
 /// Projective transform is performed.
 /// </summary>
 public static __vmtype__ TransformPosProjFull(__nmtype__ m, __ftype__ p)
 {
     return(new __vmtype__(TransformPos(m, p), m.M10 * p + m.M11));
 }
示例#6
0
 /// <summary>
 /// Transforms point p (v.w is presumed 1.0) by matrix m.
 /// No projective transform is performed.
 /// </summary>
 public static __ftype__ TransformPos(__nmtype__ m, __ftype__ p)
 {
     return(m.M00 * p + m.M01);
 }
示例#7
0
 //# if (m == 2) {
 /// <summary>
 /// Transforms direction vector v (v.w is presumed 0.0) by matrix m.
 /// </summary>
 public static __ftype__ TransformDir(__nmtype__ m, __ftype__ v)
 {
     return(m.M00 * v);
 }
示例#8
0
 /// <summary>
 /// Returns the Manhatten (or 1-) distance between two matrices.
 /// </summary>
 public static __ftype__ Distance1(__nmtype__ a, __nmtype__ b)
 {
     return/*# n.ForEach(i => { m.ForEach(j => { */
            (Fun.Abs(b.M__i____j__ - a.M__i____j__) /*# }, add); }, add); */);
 }
示例#9
0
 //# if (m == n) {
 public static __vmtype__ TransposedMultiply(__vntype__ v, __nmtype__ m)
 {
     return(new __vmtype__(/*# m.ForEach(q => { */
                /*# n.ForEach(r => { var f = fields[r]; */ v.__f__ * m.M__r____q__ /*# },
                                                                                    * add); }, comma); */));
 }
示例#10
0
        //#         }
        //#     }
        //# }
        #endregion

        #region Matrix/Vector Multiplication

        public static __vntype__ Multiply(__nmtype__ m, __vmtype__ v)
        {
            return(new __vntype__(/*# n.ForEach(r => { */
                       /*# m.ForEach(q => { var f = fields[q]; */ m.M__r____q__ * v.__f__ /*# },
                                                                                           * add); }, comma); */));
        }
示例#11
0
 public static __nmtype1__ __opact__(__ftype1__ s, __nmtype__ m)
 {
     return(new __nmtype1__(/*# n.ForEach(r => { */
                /*# m.ForEach(s => { */ s__op__m.M__r____s__ /*# }, comma); }, comma); */));
 }
示例#12
0
 /// <summary>
 /// Returns the p-distance between two matrices.
 /// </summary>
 public static __ctype__ Distance(__nmtype__ a, __nmtype__ b, __ctype__ p)
 {
     return((                                                 /*# n.ForEach(i => { m.ForEach(j => { */
                Fun.Abs(b.M__i____j__ - a.M__i____j__).Pow(p) /*# }, add); }, add); */
                ).Pow(1 / p));
 }
示例#13
0
 /// <summary>
 /// Returns the Euclidean (or 2-) distance between two matrices.
 /// </summary>
 public static __ctype__ Distance2(__nmtype__ a, __nmtype__ b)
 {
     return /*# if (ctype != "double") {*/ ((__ctype__)/*# } */ Fun.Sqrt(/*# n.ForEach(i => { m.ForEach(j => { */
                                                Fun.Square(b.M__i____j__ - a.M__i____j__) /*# }, add); }, add); */));
 }
示例#14
0
 /// <summary>
 /// Transforms point p (p.w is presumed 1.0) by matrix m.
 /// Projective transform is performed.
 /// </summary>
 public static __vmtype__ TransformPosProjFull(__nmtype__ m, __vmsub1type__ p)
 {
     return(new __vmtype__(                                                                                                  /*# m.ForEach(s => { */
                (/*# mfields.Take(msub1).ForEach((fr, r) => { */ m.M__s____r__ * p.__fr__ /*#}, add);*/ + m.M__s____msub1__) /*#}, comma);*/
                ));
 }
示例#15
0
 public static bool __bopname__(__ftype__ s, __nmtype__ a)
 {
     return/*# n.ForEach(i => { m.ForEach(j => { */
            (s__bop__a.M__i____j__ /*# }, andand); }, andand); */);
 }
示例#16
0
 //# } else { // n != m
 /// <summary>
 /// Transforms point p (p.w is presumed 1.0) by matrix m.
 /// Projective transform is performed.
 /// </summary>
 public static __vmsub1type__ TransformPosProj(__nmtype__ m, __vmsub1type__ p)
 {
     return(TransformDir(m, p));
 }
示例#17
0
 /// <summary>
 /// Returns if all entries in the matrix a are approximately equal to the respective entries in matrix b.
 /// </summary>
 public static bool ApproximatelyEquals(__nmtype__ a, __nmtype__ b, __ftype__ epsilon)
 {
     return(DistanceMax(a, b) <= epsilon); //Inefficient implementation, no early exit of comparisons.
 }