Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/SharpVectorModel/Paths/SvgPathSegLineto.cs @ 13005

Last change on this file since 13005 was 12762, checked in by aballeit, 9 years ago

#2283 GUI updates, Tree-chart, MCTS Version 2 (prune leaves)

File size: 1.2 KB
Line 
1using System;
2using System.Text;
3
4namespace SharpVectors.Dom.Svg
5{
6  public abstract class SvgPathSegLineto : SvgPathSeg
7  {
8    protected SvgPathSegLineto(SvgPathSegType type) : base(type)
9    {
10    }
11
12    public abstract override SvgPointF AbsXY{get;}
13
14    private SvgPointF getPrevPoint()
15    {
16      SvgPathSeg prevSeg = PreviousSeg;
17      SvgPointF prevPoint;
18      if(prevSeg == null)
19      {
20        prevPoint = new SvgPointF(0,0);
21      }
22      else
23      {
24        prevPoint = prevSeg.AbsXY;
25      }
26      return prevPoint;
27    }
28
29    public override double StartAngle
30    {
31      get
32      {
33        SvgPointF prevPoint = getPrevPoint();
34        SvgPointF curPoint = AbsXY;
35
36        double dx = curPoint.X - prevPoint.X;
37        double dy = curPoint.Y - prevPoint.Y;
38
39        double a = (Math.Atan2(dy, dx) * 180 / Math.PI);
40        a += 270;
41        a %= 360;
42        return a;
43      }
44    }
45
46    public override double EndAngle
47    {
48      get
49      {
50        double a = StartAngle;
51        a += 180;
52        a %= 360;
53        return a;
54      }
55    }
56
57    public override double Length
58    {
59      get
60      {
61        SvgPointF prevPoint = getPrevPoint();
62        SvgPointF thisPoint = AbsXY;
63
64        double dx = thisPoint.X - prevPoint.X;
65        double dy = thisPoint.Y - prevPoint.Y;
66
67        return Math.Sqrt(dx*dx+dy*dy);
68      }
69    }
70  }
71}
Note: See TracBrowser for help on using the repository browser.