prim cuts in ODE

Much thanks to Gerhard!
Merged with Darok's recent changes re: physical prims
This commit is contained in:
dan miller
2007-11-05 12:25:53 +00:00
parent 6bb1e91d41
commit fdb57b28b1
8 changed files with 507 additions and 516 deletions

View File

@@ -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;
}
}
}