示例#1
0
 public bool LessIdThan(vector v)
 {
     if (X < v.X)
     {
         return(true);
     }
     if (X > v.X)
     {
         return(false);
     }
     if (Y < v.Y)
     {
         return(true);
     }
     if (Y > v.Y)
     {
         return(false);
     }
     if (Z < v.Z)
     {
         return(true);
     }
     if (Z > v.Z)
     {
         return(false);
     }
     return(false);
 }
示例#2
0
 public void ClipSelf(vector min, vector max)
 {
     if (X < min.X)
     {
         X = min.X;
     }
     else if (max.X < X)
     {
         X = max.X;
     }
     if (Y < min.Y)
     {
         Y = min.Y;
     }
     else if (max.Y < Y)
     {
         Y = max.Y;
     }
     if (Z < min.Z)
     {
         Z = min.Z;
     }
     else if (max.Z < Z)
     {
         Z = max.Z;
     }
 }
示例#3
0
        public vector Clip(vector min, vector max)
        {
            vector v = this;

            if (v.X < min.X)
            {
                v.X = min.X;
            }
            else if (max.X < v.X)
            {
                v.X = max.X;
            }
            if (v.Y < min.Y)
            {
                v.Y = min.Y;
            }
            else if (max.Y < v.Y)
            {
                v.Y = max.Y;
            }
            if (v.Z < min.Z)
            {
                v.Z = min.Z;
            }
            else if (max.Z < v.Z)
            {
                v.Z = max.Z;
            }
            return(v);
        }
示例#4
0
文件: Obb3d.cs 项目: nQuantums/tips
 public Obb3d(Obb3f v)
 {
     Center  = new vector(v.Center);
     Extents = new vector(v.Extents);
     Ax      = new vector(v.Ax);
     Ay      = new vector(v.Ay);
     Az      = new vector(v.Az);
 }
示例#5
0
文件: Obb3d.cs 项目: nQuantums/tips
 public Obb3d(aabb aabb)
 {
     Center  = aabb.Center;
     Extents = aabb.Extents;
     Ax      = vector.AxisX;
     Ay      = vector.AxisY;
     Az      = vector.AxisZ;
 }
示例#6
0
文件: Obb3d.cs 项目: nQuantums/tips
 public Obb3d(vector center, vector extents, vector ax, vector ay, vector az)
 {
     Center  = center;
     Extents = extents;
     Ax      = ax;
     Ay      = ay;
     Az      = az;
 }
示例#7
0
        /// <summary>
        /// 3次ベジェ曲線での補間を微分する
        /// </summary>
        /// <param name="t">パラメータ</param>
        /// <param name="p0">コントロールポイント0</param>
        /// <param name="p1">コントロールポイント1</param>
        /// <param name="p2">コントロールポイント2</param>
        /// <param name="p3">コントロールポイント3</param>
        /// <returns>微分結果のベクトル</returns>
        public static vector DiffInterpolate3(element t, vector p0, vector p1, vector p2, vector p3)
        {
            var t2  = t * t;
            var ti  = 1 - t;
            var ti2 = ti * ti;

            return(p0 * (-3 * ti2) + p1 * (9 * t2 - 12 * t + 3) + p2 * (-9 * t2 + 6 * t) + p3 * (3 * t2));
        }
示例#8
0
        /// <summary>
        /// 3次ベジェ曲線で補間する
        /// </summary>
        /// <param name="t">パラメータ</param>
        /// <param name="p0">コントロールポイント0</param>
        /// <param name="p1">コントロールポイント1</param>
        /// <param name="p2">コントロールポイント2</param>
        /// <param name="p3">コントロールポイント3</param>
        /// <returns>補間された座標</returns>
        public static vector Interpolate3(element t, vector p0, vector p1, vector p2, vector p3)
        {
            var t2  = t * t;
            var t3  = t2 * t;
            var ti  = 1 - t;
            var ti2 = ti * ti;
            var ti3 = ti2 * ti;

            return(p0 * ti3 + p1 * (3 * ti2 * t) + p2 * (3 * ti * t2) + p3 * t3);
        }
示例#9
0
文件: Range3d.cs 项目: nQuantums/tips
 public Range3d(vector min, vector max, bool normalize)
 {
     if (normalize)
     {
         vector.ElementWiseMinMax(min, max, out Min, out Max);
     }
     else
     {
         Min = min;
         Max = max;
     }
 }
示例#10
0
文件: Range3d.cs 项目: nQuantums/tips
        public Range3d(IEnumerable <vector> positions)
        {
            vector min = vector.MaxValue, max = vector.MinValue;

            foreach (var p in positions)
            {
                min.ElementWiseMinSelf(p);
                max.ElementWiseMaxSelf(p);
            }
            Min = min;
            Max = max;
        }
示例#11
0
文件: Range3d.cs 项目: nQuantums/tips
        public Range3d(IEnumerable <volume> volumes)
        {
            vector min = vector.MaxValue, max = vector.MinValue;

            foreach (var v in volumes)
            {
                min.ElementWiseMinSelf(v.Min);
                max.ElementWiseMaxSelf(v.Max);
            }
            Min = min;
            Max = max;
        }
示例#12
0
 public void ElementWiseMaxSelf(vector v)
 {
     if (v.X > X)
     {
         X = v.X;
     }
     if (v.Y > Y)
     {
         Y = v.Y;
     }
     if (v.Z > Z)
     {
         Z = v.Z;
     }
 }
示例#13
0
 public void ElementWiseMinSelf(vector v)
 {
     if (v.X < X)
     {
         X = v.X;
     }
     if (v.Y < Y)
     {
         Y = v.Y;
     }
     if (v.Z < Z)
     {
         Z = v.Z;
     }
 }
示例#14
0
 static public vector ElementWiseMax(vector v1, vector v2)
 {
     if (v2.X < v1.X)
     {
         v2.X = v1.X;
     }
     if (v2.Y < v1.Y)
     {
         v2.Y = v1.Y;
     }
     if (v2.Z < v1.Z)
     {
         v2.Z = v1.Z;
     }
     return(v2);
 }
示例#15
0
            public vector this[int index] {
                get {
                    switch (index)
                    {
                    case 0:
                        return(P0);

                    case 1:
                        return(P1);

                    case 2:
                        return(P2);

                    case 3:
                        return(P3);

                    default:
                        throw new NotImplementedException();
                    }
                }
                set {
                    switch (index)
                    {
                    case 0:
                        P0 = value;
                        break;

                    case 1:
                        P1 = value;
                        break;

                    case 2:
                        P2 = value;
                        break;

                    case 3:
                        P3 = value;
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                }
            }
示例#16
0
 public static void ElementWiseMinMax(vector v1, vector v2, out vector min, out vector max)
 {
     if (v2.X < v1.X)
     {
         var t = v1.X; v1.X = v2.X; v2.X = t;
     }
     ;
     if (v2.Y < v1.Y)
     {
         var t = v1.Y; v1.Y = v2.Y; v2.Y = t;
     }
     ;
     if (v2.Z < v1.Z)
     {
         var t = v1.Z; v1.Z = v2.Z; v2.Z = t;
     }
     ;
     min = v1;
     max = v2;
 }
示例#17
0
        /// <summary>
        /// Use Newton-Raphson iteration to find better root.
        /// </summary>
        /// <param name="Q">Current fitted curve</param>
        /// <param name="P">Digitized point</param>
        /// <param name="u">Parameter value for <see cref="P"/></param>
        /// <returns>パラメータ</returns>
        static element NewtonRaphsonRootFind(cubicbezier Q, vector P, element u)
        {
            /* Compute Q(u)	*/
            var Q_u = Q.Interpolate(u);

            /* Generate control vertices for Q'	*/
            var Q1 = new vector[3];                /*  Q' and Q''			*/

            for (int i = 0; i <= 2; i++)
            {
                Q1[i] = (Q[i + 1] - Q[i]) * 3;
            }

            /* Generate control vertices for Q'' */
            var Q2 = new vector[2];

            for (int i = 0; i <= 1; i++)
            {
                Q2[i] = (Q1[i + 1] - Q1[i]) * 2;
            }

            /* Compute Q'(u) and Q''(u)	*/
            var Q1_u = Interpolate2(u, Q1[0], Q1[1], Q1[2]);
            var Q2_u = Interpolate1(u, Q2[0], Q2[1]);

            /* Compute f(u)/f'(u) */
            var Q_u_P       = Q_u - P;
            var numerator   = Q_u_P.Dot(Q1_u);
            var denominator = Q1_u.LengthSquare + Q_u_P.Dot(Q2_u);

            if (denominator == 0)
            {
                return(u);
            }

            /* u = u - f(u)/f'(u) */
            return(u - numerator / denominator);
        }
示例#18
0
文件: Range3d.cs 项目: nQuantums/tips
 public Range3d(Range3f v)
 {
     Min = new vector(v.Min);
     Max = new vector(v.Max);
 }
示例#19
0
 public element Dot(vector v)
 {
     return(X * v.X + Y * v.Y + Z * v.Z);
 }
示例#20
0
文件: Range3d.cs 项目: nQuantums/tips
 public Range3d(vector min, vector max)
 {
     Min = min;
     Max = max;
 }
示例#21
0
 public vector Cross(vector v)
 {
     return(new vector(Y * v.Z - Z * v.Y, Z * v.X - X * v.Z, X * v.Y - Y * v.X));
 }
示例#22
0
文件: Range3d.cs 项目: nQuantums/tips
 public void ExpandSelf(vector v)
 {
     Min.SubSelf(v);
     Max.AddSelf(v);
 }
示例#23
0
文件: Range3d.cs 项目: nQuantums/tips
 public Range3d(vector position)
 {
     Min = position;
     Max = position;
 }
示例#24
0
文件: Range3d.cs 项目: nQuantums/tips
 public void MergeSelf(vector v)
 {
     Min.ElementWiseMinSelf(v);
     Max.ElementWiseMaxSelf(v);
 }
示例#25
0
文件: Range3d.cs 项目: nQuantums/tips
 public volume Expand(vector v)
 {
     return(new volume(Min - v, Max + v));
 }
示例#26
0
文件: Range3d.cs 项目: nQuantums/tips
 public volume Merge(vector v)
 {
     return(new volume(vector.ElementWiseMin(Min, v), vector.ElementWiseMax(Max, v)));
 }
示例#27
0
文件: Range3d.cs 项目: nQuantums/tips
 public bool Contains(vector v)
 {
     return(Min <= v && v <= Max);
 }
示例#28
0
文件: Aabb3d.cs 项目: nQuantums/tips
 public Aabb3d(Aabb3f v)
 {
     Center  = new vector(v.Center);
     Extents = new vector(v.Extents);
 }
示例#29
0
文件: Aabb3d.cs 项目: nQuantums/tips
 public Aabb3d(vector center, vector extents)
 {
     Center  = center;
     Extents = extents;
 }
示例#30
0
文件: Aabb3d.cs 项目: nQuantums/tips
 public bool Contains(vector v)
 {
     v.SubSelf(Center);
     return(Math.Abs(v.X) <= Extents.X && Math.Abs(v.Y) <= Extents.Y && Math.Abs(v.Z) <= Extents.Z);
 }