How to draw an arc between two points
Im trying to make an application in C# to draw an Visio Drawing.
The problem is that I dont know how to implement the ElipticalArc statement in the .vdx file.
Is there a way to draw an eliptical arc between two points and thru a control point with direct3d?
[286 byte] By [
rofu] at [2007-12-24]
Well there are are infinite number of ellipses that go through 2 points so you need to define a 3rd point.
I don't know the algorithm off the top of my head but once you have 3 points you can solve for the formula of the ellipse and then you should be able to draw it.
Yes i do have 3 points. I also have the ratio of the major axis to its minor axis.
How do I solve the formula of en elipse from 3 points?
x = x0 + a cos t
y = y0 + b sin t
You have four unknowns (x0, y0, a, b), and four equations (plug in the three different points, and the fact that a/b = the_ratio), so it's just a matter of simple algebra to figure out the four constants from that.
Once you have those, you simply vary t to get your (x,y) point and draw lines between those points. The smaller the change of t the closer spaced the points will be and the smoother the curve will look.
You can also compute the value of t at the start and end positions so you know which values of t to move between.
Thanks for your answer. Im really greatful!
The below equations is for a ellipse where (x0,y0) is the center?
x = x0 + a cos t
y = y0 + b sin t
Which is the four equations?
The algebra is not simple for me =) Can you explain?
You know the x,y points you want the shape to go through. Fill in the x and y you know into those equations and rearrange them and you wil find out what the values are for x0,y0 a and b
If this level of math is beyond you then you will not get much further with computer graphics. I would try to get an algebra and geometry book.
I asume that I should solve the below equations in a system of equations.
x1 = x0 + a cos t
y1 = y0 + a r sin t
x2 = x0 + a cos t
y2= y0 + a r sin t
x3 = x0 + a cos t
y3 = y0 + a r sin t
x0, y0, a and b is unknown but I can eliminate b by using the_ratio.
How about t? t is also unknown?