From fdb57b28b164f239de0f976b967b79dc2ca5f6ae Mon Sep 17 00:00:00 2001 From: dan miller Date: Mon, 5 Nov 2007 12:25:53 +0000 Subject: prim cuts in ODE Much thanks to Gerhard! Merged with Darok's recent changes re: physical prims --- OpenSim/Region/Physics/Manager/PhysicsVector.cs | 50 +++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'OpenSim/Region/Physics/Manager/PhysicsVector.cs') diff --git a/OpenSim/Region/Physics/Manager/PhysicsVector.cs b/OpenSim/Region/Physics/Manager/PhysicsVector.cs index 7de37e4..ada2297 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsVector.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsVector.cs @@ -25,6 +25,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + +using System; + + namespace OpenSim.Region.Physics.Manager { public class PhysicsVector @@ -50,5 +54,51 @@ namespace OpenSim.Region.Physics.Manager { return "<" + X + "," + Y + "," + Z + ">"; } + + // Operations + public static PhysicsVector operator +(PhysicsVector a, PhysicsVector b) + { + return new PhysicsVector(a.X + b.X, a.Y + b.Y, a.Z + b.Z); + } + + public static PhysicsVector operator -(PhysicsVector a, PhysicsVector b) + { + return new PhysicsVector(a.X - b.X, a.Y - b.Y, a.Z - b.Z); + } + + public static PhysicsVector cross(PhysicsVector a, PhysicsVector b) + { + return new PhysicsVector(a.Y * b.Z - a.Z * b.Y, a.Z * b.X - a.X * b.Z, a.X * b.Y - a.Y * b.X); + } + + public float length() + { + return (float)Math.Sqrt(X*X + Y*Y + Z*Z); + } + + public static PhysicsVector operator / (PhysicsVector v, float f) + { + return new PhysicsVector(v.X / f, v.Y / f, v.Z / f); + } + + public static PhysicsVector operator *(PhysicsVector v, float f) + { + return new PhysicsVector(v.X * f, v.Y * f, v.Z * f); + } + + public static PhysicsVector operator *(float f, PhysicsVector v) + { + return v * f; + } + + public virtual bool IsIdentical(PhysicsVector v, float tolerance) + { + PhysicsVector diff = this - v; + float d = diff.length(); + if (d < tolerance) + return true; + + return false; + } } } \ No newline at end of file -- cgit v1.1