majid
majid

Reputation: 9

How to draw SQL Server "circularstring" in C#

SQL Server has a spatial type "circularstring" that is collection of odd points. How can I draw this type in c#. Drawarc works based on angles while in circularstring we have just points. Drawcurve works based on the points but the result is not the same as circularstring. With three points, circularstring is an arc of the circle pass through that points while curve is not.

Upvotes: -2

Views: 500

Answers (1)

TaW
TaW

Reputation: 54453

The basic solution could look like this:

  • Take three points A,B,C (blue) and create the arc.
  • Take the last one plus the next two and create the next arc.
  • Continue until all points are used.
  • If the number of points is even or if two consecutive points are the same the data are invalid.

To create the arc:

  • Find the center M (green) of the circle (the crossing of the yellow lines)
  • Find the (clockwise) angle between the x-axis and the connection between M and A (starting angle, orange)
  • Find the angle between M and A and C (sweep angle, orange)

Now you can draw the arc.

enter image description here

The short yellow lines connect the points; the long ones stand perpendicular on them.

Upvotes: 2

Related Questions