aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Meshing/HelperTypes.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/Meshing/HelperTypes.cs')
-rw-r--r--OpenSim/Region/Physics/Meshing/HelperTypes.cs77
1 files changed, 77 insertions, 0 deletions
diff --git a/OpenSim/Region/Physics/Meshing/HelperTypes.cs b/OpenSim/Region/Physics/Meshing/HelperTypes.cs
index 6c4a163..7b17a3f 100644
--- a/OpenSim/Region/Physics/Meshing/HelperTypes.cs
+++ b/OpenSim/Region/Physics/Meshing/HelperTypes.cs
@@ -39,6 +39,83 @@ public class Vertex : PhysicsVector, IComparable<Vertex>
39 { 39 {
40 } 40 }
41 41
42 public float length()
43 {
44 return (float)Math.Sqrt(X * X + Y * Y + Z * Z);
45 }
46
47 public Vertex normalize()
48 {
49 float tlength = length();
50 if (tlength != 0)
51 {
52 return new Vertex(X / tlength, Y / tlength, Z / tlength);
53 }
54 else
55 {
56 return new Vertex(0, 0, 0);
57 }
58 }
59
60 public Vertex cross(Vertex v)
61 {
62 return new Vertex(Y * v.Z - Z * v.Y, Z * v.X - X * v.Z, X * v.Y - Y * v.X);
63 }
64
65 public static Vertex operator +(Vertex v1, Vertex v2)
66 {
67 return new Vertex(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z);
68 }
69
70 public static Vertex operator -(Vertex v1, Vertex v2)
71 {
72 return new Vertex(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z);
73 }
74
75 public static Vertex operator *(Vertex v1, Vertex v2)
76 {
77 return new Vertex(v1.X * v2.X, v1.Y * v2.Y, v1.Z * v2.Z);
78 }
79
80 public static Vertex operator +(Vertex v1, float am)
81 {
82 v1.X += am;
83 v1.Y += am;
84 v1.Z += am;
85 return v1;
86 }
87 public static Vertex operator -(Vertex v1, float am)
88 {
89 v1.X -= am;
90 v1.Y -= am;
91 v1.Z -= am;
92 return v1;
93 }
94 public static Vertex operator *(Vertex v1, float am)
95 {
96 v1.X *= am;
97 v1.Y *= am;
98 v1.Z *= am;
99 return v1;
100 }
101 public static Vertex operator /(Vertex v1, float am)
102 {
103 if (am == 0f)
104 {
105 return new Vertex(0f,0f,0f);
106 }
107 v1.X /= am;
108 v1.Y /= am;
109 v1.Z /= am;
110 return v1;
111 }
112
113
114 public float dot(Vertex v)
115 {
116 return X * v.X + Y * v.Y + Z * v.Z;
117 }
118
42 public Vertex(PhysicsVector v) 119 public Vertex(PhysicsVector v)
43 : base(v.X, v.Y, v.Z) 120 : base(v.X, v.Y, v.Z)
44 { 121 {