public void TestMassProperties() { Box3 testBox = new Box3( Matrix.CreateTranslation(105.0f, 110.0f, 115.0f), new Vector3(5.0f, 10.0f, 15.0f) // these are extents, not dimensions! ); Assert.AreEqual( new Vector3(105.0f, 110.0f, 115.0f), testBox.CenterOfMass, "Center of mass is correctly positioned" ); Assert.AreEqual(6000.0f, testBox.Mass, "Mass of box is exactly determined"); Assert.AreEqual(2200.0f, testBox.SurfaceArea, "Surface area of box is exactly determined"); }
/// <summary>Visit an oriented box</summary> /// <param name="box">Box to visit</param> public abstract void Visit(Box3 box);
/// <summary>Determines if the volume clips the box</summary> /// <param name="box">Box that will be checked for intersection</param> /// <returns>True if the objects overlap</returns> public bool Intersects(Box3 box) { return Collisions.AabbObbCollider.CheckContact( Extents, box.Transform, box.Extents ); }
public Box3(Box3 other) : this(other.Transform, other.Extents) { }
/// <summary>Determines where the range clips a box</summary> /// <param name="box">Box that will be checked for intersection</param> /// <returns>The times at which the range enters or leaves the volume</returns> public LineContacts FindContacts(Box3 box) { // Convert line to box coordinates Vector3 offset = Origin - box.Center; Vector3 relativePosition = new Vector3( Vector3.Dot(offset, box.Transform.Right), Vector3.Dot(offset, box.Transform.Up), Vector3.Dot(offset, box.Transform.Forward) ); Vector3 relativeDirection = new Vector3( Vector3.Dot(Direction, box.Transform.Right), Vector3.Dot(Direction, box.Transform.Up), Vector3.Dot(Direction, box.Transform.Forward) ); return Collisions.Ray3Aabb3Collider.FindContacts( relativePosition, relativeDirection, box.Dimensions / 2.0f ); }
/// <summary>Determines if the volume clips the box</summary> /// <param name="box">Box that will be checked for intersection</param> /// <returns>True if the objects overlap</returns> public bool Intersects(Box3 box) { throw new NotImplementedException("Not implemented yet"); }
/// <summary>Determines if the volume clips the box</summary> /// <param name="box">Box that will be checked for intersection</param> /// <returns>True if the objects overlap</returns> public bool Intersects(Box3 box) { return Collisions.ObbSphereCollider.CheckContact( box.Transform, box.Extents, this.Center, this.Radius ); }
/// <summary>Determines if the volume clips the box</summary> /// <param name="box">Box that will be checked for intersection</param> /// <returns>True if the objects overlap</returns> public bool Intersects(Box3 box) { return(Collisions.ObbObbCollider.CheckContact( this.Transform, this.Extents, box.Transform, box.Extents )); }
/// <summary>Determines where the range clips a box</summary> /// <param name="box">Box that will be checked for intersection</param> /// <returns>The times at which the range enters or leaves the volume</returns> public LineContacts FindContacts(Box3 box) { throw new NotImplementedException(); /* // Convert line to box coordinates Vector3 offset = Start - box.Center; Vector3 relativePosition = new Vector3( Vector3.Dot(offset, box.Transform.Right), Vector3.Dot(offset, box.Transform.Up), Vector3.Dot(offset, box.Transform.Forward) ); Vector3 direction = End - Start; Vector3 relativeDirection = new Vector3( Vector3.Dot(direction, box.Transform.Right), Vector3.Dot(direction, box.Transform.Up), Vector3.Dot(direction, box.Transform.Forward) ); return filterContacts( Collisions.Line3Aabb3Collider.FindContacts( relativePosition, relativeDirection, box.Dimensions / 2.0f ) ); */ }
/// <summary>Determines if the volume clips the box</summary> /// <param name="box">Box that will be checked for intersection</param> /// <returns>True if the objects overlap</returns> public bool Intersects(Box3 box) { return(Collisions.ObbSphereCollider.CheckContact( box.Transform, box.Extents, this.Center, this.Radius )); }
/// <summary>Determines where the range clips a box</summary> /// <param name="box">Box that will be checked for intersection</param> /// <returns>The times at which the range enters or leaves the volume</returns> public LineContacts FindContacts(Box3 box) { // Convert line to box coordinates Vector3 difference = Offset - box.Center; Vector3 relativeCenter = new Vector3( Vector3.Dot(difference, box.Transform.Right), Vector3.Dot(difference, box.Transform.Up), Vector3.Dot(difference, box.Transform.Forward) ); Vector3 relativeDirection = new Vector3( Vector3.Dot(Direction, box.Transform.Right), Vector3.Dot(Direction, box.Transform.Up), Vector3.Dot(Direction, box.Transform.Forward) ); return Collisions.Line3Aabb3Collider.FindContacts( relativeCenter, relativeDirection, box.Dimensions / 2.0f ); }