123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
-
- using System;
- namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet
- {
- public class float4
- {
- public float x;
- public float y;
- public float z;
- public float w;
- public float4()
- {
- x = 0;
- y = 0;
- z = 0;
- w = 0;
- }
- public float4(float _x, float _y, float _z, float _w)
- {
- x = _x;
- y = _y;
- z = _z;
- w = _w;
- }
- public float4(float3 v, float _w)
- {
- x = v.x;
- y = v.y;
- z = v.z;
- w = _w;
- }
- public float4(float4 f)
- {
- x = f.x;
- y = f.y;
- z = f.z;
- w = f.w;
- }
- public float this[int i]
- {
- get
- {
- switch (i)
- {
- case 0: return x;
- case 1: return y;
- case 2: return z;
- case 3: return w;
- }
- throw new ArgumentOutOfRangeException();
- }
- }
- public float3 xyz()
- {
- return new float3(x, y, z);
- }
- public void setxyz(float3 xyz)
- {
- x = xyz.x;
- y = xyz.y;
- z = xyz.z;
- }
- public override int GetHashCode()
- {
- return x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode() ^ w.GetHashCode();
- }
- public override bool Equals(object obj)
- {
- float4 f = obj as float4;
- if (f == null)
- return false;
- return this == f;
- }
- public static float4 Homogenize(float3 v3)
- {
- return Homogenize(v3, 1.0f);
- }
-
-
- public static float4 Homogenize(float3 v3, float w)
- {
- return new float4(v3.x, v3.y, v3.z, w);
- }
- public static float4 cmul(float4 a, float4 b)
- {
- return new float4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
- }
- public static float4 operator +(float4 a, float4 b)
- {
- return new float4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
- }
- public static float4 operator -(float4 a, float4 b)
- {
- return new float4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
- }
- public static float4 operator *(float4 v, float4x4 m)
- {
- return v.x * m.x + v.y * m.y + v.z * m.z + v.w * m.w;
- }
- public static bool operator ==(float4 a, float4 b)
- {
-
- if (System.Object.ReferenceEquals(a, b))
- return true;
-
- if (((object)a == null) || ((object)b == null))
- return false;
- return (a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w);
- }
- public static bool operator !=(float4 a, float4 b)
- {
- return !(a == b);
- }
- public static float4 operator *(float4 v, float s)
- {
- return new float4(v.x * s, v.y * s, v.z * s, v.w * s);
- }
- public static float4 operator *(float s, float4 v)
- {
- return new float4(v.x * s, v.y * s, v.z * s, v.w * s);
- }
- }
- }
|