123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- /* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * <http://codesuppository.googlecode.com> by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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);
- }
- //C++ TO C# CONVERTER NOTE: C# does not allow default values for parameters. Overloaded methods are inserted above.
- //ORIGINAL LINE: float4 Homogenize(const float3 &v3, const float &w =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; // yes this actually works
- }
- public static bool operator ==(float4 a, float4 b)
- {
- // If both are null, or both are same instance, return true.
- if (System.Object.ReferenceEquals(a, b))
- return true;
- // If one is null, but not both, return false.
- 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);
- }
- }
- }
|