Exemplo n.º 1
0
    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");

    }
Exemplo n.º 2
0
        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");
        }
Exemplo n.º 3
0
 /// <summary>Visit an oriented box</summary>
 /// <param name="box">Box to visit</param>
 public abstract void Visit(Box3 box);
Exemplo n.º 4
0
 /// <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
   );
 }
Exemplo n.º 5
0
 public Box3(Box3 other)
   : this(other.Transform, other.Extents) { }
Exemplo n.º 6
0
    /// <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
      );

    }
Exemplo n.º 7
0
 /// <summary>Visit an oriented box</summary>
 /// <param name="box">Box to visit</param>
 public abstract void Visit(Box3 box);
Exemplo n.º 8
0
 /// <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");
 }
Exemplo n.º 9
0
 /// <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
   );
 }
Exemplo n.º 10
0
 public Box3(Box3 other)
     : this(other.Transform, other.Extents)
 {
 }
Exemplo n.º 11
0
 /// <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
                ));
 }
Exemplo n.º 12
0
    /// <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
              )
            );
      */
    }
Exemplo n.º 13
0
 /// <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
                ));
 }
Exemplo n.º 14
0
 /// <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");
 }
Exemplo n.º 15
0
    /// <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
      );

    }