summaryrefslogtreecommitdiffstats
path: root/Master/CGuCAD/projects/Markus/PolyNode.cs
blob: 1eb5d56fc8f529c2407aca70fc9e89a353e58d72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using Autodesk.AutoCAD.Geometry;
using System.IO;
using System.Globalization;

namespace Praktikum
{
    class PolyNode
    {
        public int iNodeIndex;
        public Point2d p2DPoint;

        public double GetWinkelPoint(PolyNode ZielPunkt)
        {
            return GetWinkelPoint(ZielPunkt.p2DPoint);
        }

        public double GetWinkelPoint(Point2d ZielPunkt)
        {
            return CalcAngle(GetAnglePointToPoint(p2DPoint, ZielPunkt));
        }

        private double CalcAngle(double dRadiant)
        {
            double RotationsWinkelGrad = dRadiant * 180.0f / Math.PI;

            if (RotationsWinkelGrad < 0)
                return 360 + RotationsWinkelGrad;
            else
                return RotationsWinkelGrad;
        }

        private double GetAnglePointToPoint(Point2d PAusgangspunkt, Point2d PKreispunkt)
        {
            return (double)(Math.Atan2((double)(PKreispunkt.Y - PAusgangspunkt.Y), (double)(PKreispunkt.X - PAusgangspunkt.X)));
        }

        public double Distance(Point2d p2dPunkt)
        {
            double xDist = (p2dPunkt.X - p2DPoint.X);
            double yDist = (p2dPunkt.Y - p2DPoint.Y);

            return (Math.Sqrt(xDist * xDist + yDist * yDist));
        }

        public double Distance(PolyNode p2dPunkt)
        {
            return Distance(p2dPunkt.p2DPoint);
        } 
    }
}