Nez.Portable/Physics/Verlet/Constraints/DistanceConstraint.cs
/// <summary>
/// creates a faux angle constraint by figuring out the required distance from a to c for the given angle
/// </summary>
/// <param name="a">The alpha component.</param>
/// <param name="center">Center.</param>
/// <param name="c">C.</param>
/// <param name="stiffness">Stiffness.</param>
/// <param name="angleInDegrees">Angle in degrees.</param>
creates a faux angle constraint by figuring out the required distance from a to c for the given angle
creates a faux angle constraint by figuring out the required distance from a to c for the given angle
public static DistanceConstraint create(
            Particle a,
            Particle center,
            Particle c,
            float stiffness,
            float angleInDegrees)
        {
            var aToCenter = Vector2.Distance(a.position, center.position);
            var cToCenter = Vector2.Distance(c.position, center.position);
            var distance = Mathf.sqrt(
                aToCenter * aToCenter + cToCenter * cToCenter
                - (2 * aToCenter * cToCenter * Mathf.cos(angleInDegrees * Mathf.deg2Rad)));
            return new DistanceConstraint(a, c, stiffness, distance);
        }
public static DistanceConstraint create ( Particle a , Particle center , Particle c , float stiffness , float angleInDegrees ) { var aToCenter = Vector2 . Distance ( a . position , center . position ) ; var cToCenter = Vector2 . Distance ( c . position , center . position ) ; var distance = Mathf . sqrt ( aToCenter * aToCenter + cToCenter * cToCenter - ( 2 * aToCenter * cToCenter * Mathf . cos ( angleInDegrees * Mathf . deg2Rad ) ) ) ; return new DistanceConstraint ( a , c , stiffness , distance ) ; }
creates a faux angle constraint by figuring out the required distance from a to c for the given angle
creates a faux angle constraint by figuring out the required distance from a to c for the given angle
a
Particle
The alpha component.
The alpha component .
center
Particle
None
c
Particle
None
stiffness
float
None
angleInDegrees
float
Angle in degrees.
Angle in degrees .