Beispiel #1
0
        public Circle3XZ(Vector3 center, Vector3 pointOnCircle)
        {
            if (pointOnCircle == center)
            {
                this.center     = center;
                this.radius     = 0f;
                this.angleStart = 0f;

                return;
            }

            this.center     = center;
            center.y        = 0f;
            pointOnCircle.y = 0f;
            Vector3 _radiusVector = pointOnCircle - center;

            this.radius = _radiusVector.magnitude;
            //this.angleStart = MathPLT.AngleSigned(_radiusVector, Vector3.right, Vector3.up) + Mathf.PI;
            this.angleStart = MathPLT.AngleSigned(_radiusVector, Vector3.right, Vector3.up);
        }
Beispiel #2
0
        /// <summary>
        /// Returns the angle, in radians, between a line pointing from the center to a given point, and the line pointing from the center to the start point (t = 0f).
        /// </summary>
        /// <param name="position"></param>
        /// <returns></returns>
        public float AngleFromStartXZ(Vector3 position)
        {
            float _angleFromStart = 0f;

            Vector3 _pointVector = position - this.center;

            _pointVector.y = 0f;
            _pointVector.Normalize();
            Vector3 _zeroVector = this.Position(0f) - this.center;

            _zeroVector.y = 0f;
            _zeroVector.Normalize();

            _angleFromStart = MathPLT.AngleSigned(_pointVector, _zeroVector, Vector3.up);
            if (_angleFromStart < 0f)
            {
                _angleFromStart += 2f * Mathf.PI;
            }

            return(_angleFromStart);
        }