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]
# 1
No. You will have to do the math yourself and draw small line segments..
TheZMan at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 2

Thanks for your answer.

Do you know where to find an algorithm to draw an eliptical arc?

Maybe there is a book that brings up this subject?

rofu at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 3

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.

TheZMan at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 4

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?

rofu at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 5
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.

sylvan at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 6

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?

rofu at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 7

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.

TheZMan at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 8
Do you know any good algebra and geometry book?
rofu at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 9
Any will do. Are you still in school? If so just use whatever book your school uses to teach algebra. Ask your math teacher about this problem and he/she will likely be more than happy to help you.
sylvan at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 10

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?

rofu at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 11

Yetti helped me to solve the problem in a math forum.

http://www.mathlinks.ro/Forum/viewtopic.php?p=644880#644880

rofu at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...