EpForceDirectedGraph.cs.AbstractVector.Magnitude C# (CSharp) Method

Magnitude() public abstract method

public abstract Magnitude ( ) : float
return float
        public abstract float Magnitude();

Usage Example

Ejemplo n.º 1
0
        protected void applyHookesLaw()
        {
            foreach (Edge e in graph.edges)
            {
                Spring         spring       = GetSpring(e);
                AbstractVector d            = spring.point2.position - spring.point1.position;
                float          displacement = spring.Length - d.Magnitude();
                AbstractVector direction    = d.Normalize();

                if (spring.point1.node.Pinned && spring.point2.node.Pinned)
                {
                    spring.point1.ApplyForce(direction * 0.0f);
                    spring.point2.ApplyForce(direction * 0.0f);
                }
                else if (spring.point1.node.Pinned)
                {
                    spring.point1.ApplyForce(direction * 0.0f);
                    spring.point2.ApplyForce(direction * (spring.K * displacement));
                }
                else if (spring.point2.node.Pinned)
                {
                    spring.point1.ApplyForce(direction * (spring.K * displacement * -1.0f));
                    spring.point2.ApplyForce(direction * 0.0f);
                }
                else
                {
                    spring.point1.ApplyForce(direction * (spring.K * displacement * -0.5f));
                    spring.point2.ApplyForce(direction * (spring.K * displacement * 0.5f));
                }
            }
        }
All Usage Examples Of EpForceDirectedGraph.cs.AbstractVector::Magnitude