ace/Source/ACE.Server/Physics/Ray.cs
gmriggs 6311882f18 Adding PartArray, PhysicsPart, Sphere, SphereTests (#644)
* Adding PartArray, PhysicsPart, Sphere, SphereTests

* Adding missing files
2018-02-22 01:57:02 -05:00

39 lines
1 KiB
C#

using System;
using System.Numerics;
namespace ACE.Server.Physics
{
public class Ray
{
public Vector3 Point;
public Vector3 Dir;
public float Length;
public Ray()
{
}
public Ray(Vector3 point, Vector3 dir, float length)
{
Point = point;
Dir = dir;
Length = length;
}
public Ray(Vector3 startPoint, Vector3 offset)
{
if (Math.Abs(offset.X - startPoint.X) > PhysicsGlobals.EPSILON ||
Math.Abs(offset.Y - startPoint.Y) > PhysicsGlobals.EPSILON ||
Math.Abs(offset.Z - startPoint.Z) > PhysicsGlobals.EPSILON)
{
Length = (float)Math.Sqrt(offset.X * offset.X + offset.Y * offset.Y + offset.Z * offset.Z);
var invLength = 1.0f / Length;
Point = startPoint;
Dir = new Vector3(offset.X * invLength, offset.Y * invLength, offset.Z * invLength);
}
}
}
}