Nez.Vector2Ext.angle C# (CSharp) Méthode

angle() private méthode

private angle ( Vector2 from, Vector2 to ) : float
from Microsoft.Xna.Framework.Vector2
to Microsoft.Xna.Framework.Vector2
Résultat float
		public static float angle( Vector2 from, Vector2 to )
		{
			normalize( ref from );
			normalize( ref to );
			return Mathf.acos( Mathf.clamp( Vector2.Dot( from, to ), -1f, 1f ) ) * Mathf.rad2Deg;
		}

Usage Example

            public void setFusedData(bool shouldFuseBottom, ref Segment segment)
            {
                // store the angle off for later. For extreme angles we add extra verts to smooth the joint
                angle = Vector2Ext.angle(segment.point.position - point.position, nextPoint.position - point.position);
                this.shouldFuseBottom = shouldFuseBottom;

                if (shouldFuseBottom)
                {
                    hasFusedPoint = ShapeCollisions.lineToLine(segment.bl, segment.br, bl, br, out fusedPoint);
                }
                else
                {
                    hasFusedPoint = ShapeCollisions.lineToLine(segment.tl, segment.tr, tl, tr, out fusedPoint);
                }
            }