Example #1
0
        /// <summary>
        /// Returns the unsigned shortest distance from a point to this line. Also called triangle height.
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        public float PerpendicularDistance(Vector2 point) {
            float a = (PointB - point).magnitude;

            Vector2 BP = point - PointB;
            Vector2 BA = -Vector;
            float angleB = Hedra.Angle(BP, BA) * Mathf.Deg2Rad;

            float height = a * Mathf.Sin(angleB);
            return Mathf.Abs(height);
        }
Example #2
0
        public RegularPolygon(Vector2 position, int vertices, float radius, float rotation)
        {
            this.Radius   = radius;
            center        = position;
            this.rotation = rotation;
            vertexCount   = vertices;

            Init();

            Angle = Hedra.Angle(Edges[0], Edges[1]);
        }
Example #3
0
        public RegularPolygon(RegularPolygon other)
        {
            this.Radius   = other.Radius;
            this.center   = other.Center;
            this.rotation = other.Rotation;
            this.Collider = other.Collider;
            vertexCount   = other.Vertices.Length;

            Init();

            Angle = Hedra.Angle(Edges[0], Edges[1]);
        }
Example #4
0
        public RegularPolygon(CircleCollider2D collider, int vertices)
        {
            Transform owner = collider.gameObject.transform;

            Collider    = collider;
            Radius      = collider.radius;
            rotation    = owner.rotation.eulerAngles.z;
            center      = collider.bounds.center;
            vertexCount = vertices;

            Init();

            Angle = Hedra.Angle(Edges[0], Edges[1]);
        }