예제 #1
0
        public Angle(float value, AngleType angleType = AngleType.Degree)
        {
            switch (angleType)
            {
            case AngleType.Degree:
                _degrees = value < 0 ? value % 361 + 360 : value % 361;
                break;

            case AngleType.Gradian:
                value    = AngleHelper.GradianToDegree(value);
                _degrees = value < 0 ? value % 361 + 360 : value % 361;
                break;

            case AngleType.Radian:
                value    = AngleHelper.RadianToDegree(value);
                _degrees = value < 0 ? value % 361 + 360 : value % 361;
                break;

            case AngleType.Turn:
                value    = AngleHelper.TurnToDegree(value);
                _degrees = value < 0 ? value % 361 + 360 : value % 361;
                break;

            default:
                _degrees = 0f;
                break;
            }
        }
예제 #2
0
파일: Ray2D.cs 프로젝트: hedocode/GameBase
 public Ray2D(ICoordinates startPoint, Angle angle)
 {
     _startPoint     = (Vector2D)startPoint;
     _angleFromXAxis = angle;
     Slope           = AngleHelper.AngleToSlope(angle);
     YAt0            = startPoint.Y - Slope * startPoint.X;
 }
예제 #3
0
파일: Ray2D.cs 프로젝트: hedocode/GameBase
 public Ray2D(Point point2D, Angle angle)
 {
     _startPoint     = (Vector2D)point2D;
     _angleFromXAxis = angle;
     Slope           = AngleHelper.AngleToSlope(angle);
     YAt0            = point2D.Y - Slope * point2D.X;
 }
예제 #4
0
        public static double DistanceBetween(Segment segment1, Segment segment2)
        {
            if (Intersects(segment1, segment2))
            {
                return(0);
            }

            if (segment1.Slope == segment2.Slope)
            {
                return(Math.Sin(AngleHelper.SlopeToRadian(segment1.Slope))
                       * (segment1.Slope * Math.Abs(segment1.YAt0 - segment2.YAt0)));
            }
            if (segment1.Slope > segment2.Slope)
            {
                return(DistanceBetween(segment1.Point2, segment2.Point2));
            }
            return(DistanceBetween(segment1.Point1, segment2.Point1));
        }
예제 #5
0
 public Angle(Vector2 vector)
 {
     _degrees = AngleHelper.RadianToDegree((float)Math.Atan2(-vector.Y, vector.X));
 }
예제 #6
0
 public Vector2 GetVector(float vectorLenght) => AngleHelper.DegreeToVector(_degrees, vectorLenght);
예제 #7
0
 public Vector2 GetUnitVector() => AngleHelper.DegreeToVector(_degrees, 1);
예제 #8
0
 public Line(ICoordinates point, Angle angle)
 {
     Slope = AngleHelper.AngleToSlope(angle);
     YAt0  = point.Y - point.X * Slope;
 }