/// Apply an impulse at a point. This immediately modifies the velocity.
 /// It also modifies the angular velocity if the point of application
 /// is not at the center of mass.
 public void ApplyLinearImpluse(Fix64Vec2 impluse, Fix64Vec2 worldPoint)
 {
     Parallel2D.ApplyLinearImpulse(_body2D, worldPoint, impluse);
 }
 //Apply a force at a world point
 public void ApplyForce(Fix64Vec2 force, Fix64Vec2 worldPoint)
 {
     Parallel2D.ApplyForce(_body2D, worldPoint, force);
 }
 //Apply an impulse to the center of mass. This immediately modifies the velocity.
 public void ApplyLinearImpulse(Fix64Vec2 impluse)
 {
     Parallel2D.ApplyLinearImpulseToCenter(_body2D, impluse);
 }
Example #4
0
 public void UpdateShape(Fix64Vec2 size)
 {
     _size = size;
     UpdateShape(_root);
 }
 //============================== Force and Torque ==============================
 //Apply a force to the center of mass
 public void ApplyForce(Fix64Vec2 force)
 {
     Parallel2D.ApplyForceToCenter(_body2D, force);
 }
Example #6
0
        public static Fix64Vec2 Intersection(Fix64Vec2 a1, Fix64Vec2 v, Fix64 range, Fix64Vec2 b1, Fix64Vec2 b2, out bool found)
        {
            Fix64Vec2 a2 = a1 + v.normalized * range;

            return(Intersection(a1, a2, b1, b2, out found));
        }
Example #7
0
        public static Fix64Vec2 Intersection(Fix64Vec2 a1, Fix64Vec2 a2, Fix64Vec2 b1, Fix64Vec2 b2, out bool found)
        {
            Fix64 tmp = (b2.x - b1.x) * (a2.y - a1.y) - (b2.y - b1.y) * (a2.x - a1.x);

            if (tmp == Fix64.zero)
            {
                // No solution!
                found = false;
                return(Fix64Vec2.zero);
            }

            Fix64 mu = ((a1.x - b1.x) * (a2.y - a1.y) - (a1.y - b1.y) * (a2.x - a1.x)) / tmp;

            found = true;

            return(new Fix64Vec2(
                       b1.x + (b2.x - b1.x) * mu,
                       b1.y + (b2.y - b1.y) * mu
                       ));
        }
Example #8
0
 //Cross product of two vectors
 public static Fix64 Cross(Fix64Vec2 a, Fix64Vec2 b)
 {
     return(a.x * b.y - a.y * b.x);
 }
Example #9
0
 //Dot product of two vectors
 public static Fix64 Dot(Fix64Vec2 a, Fix64Vec2 b)
 {
     return(a.x * b.x + a.y * b.y);
 }
Example #10
0
 //Distance between two points
 public static Fix64 Distance(Fix64Vec2 a, Fix64Vec2 b)
 {
     return((a - b).Length());
 }