creating a ellispse at any aspect angle

Reply

Join Date: Sep 2004
Posts: 4
Reputation: aviral82 is an unknown quantity at this point 
Solved Threads: 0
aviral82 aviral82 is offline Offline
Newbie Poster

creating a ellispse at any aspect angle

 
0
  #1
Oct 6th, 2004
hi all ,
i have to create an ellispe the inputs are
major axis , minor axis , and the angle of the major axis
the ellipse needs to be tilted.
thanks
aviral
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 18
Reputation: Nuez_Jr is an unknown quantity at this point 
Solved Threads: 1
Nuez_Jr's Avatar
Nuez_Jr Nuez_Jr is offline Offline
Newbie Poster

Re: creating a ellispse at any aspect angle

 
0
  #2
Oct 6th, 2004
Originally Posted by aviral82
hi all ,
i have to create an ellispe the inputs are
major axis , minor axis , and the angle of the major axis
the ellipse needs to be tilted.
thanks
aviral

Construct the formula for the ellipse in standard position, and then use an affine transformation to rotate it. Better yet, if you need to draw it to screen, construct the parametric formula for the ellipse and transform that.

A circle in standard position is given thus:
x = r cos(t)
y = r sin(t)
t = 0..1

Change it to an ellipse by substituting the major and minor axes into the position of r in the x and y equations:

x = r_maj * cos(t)
y = r_min * sin(t)

Then multiply by the transformation matrix
[ [ cos(a), sin(a)] [-sin(a), cos(a)] ]
To rotate the whole thing counterclockwise by angle 'a'.

<r_maj*cos(t), r_min*sin(t)> * [[cos(a),sin(a)][-sin(a),cos(a)]] =

Which, after tedious and error-prone-when-done-by-hand matrix multiplication, gives

x = r_maj*cos(t)*cos(a) + r_min*sin(t)*-sin(a)
y = r_maj*cos(t)*sin(a) + r_min*sin(t)*cos(a)

This is just a quick answer; there are probably better and faster ways to get the points on an ellipse, but this'll definitely draw the right shape. If you're drawing pixel-by-pixel the line may look a bit chunky in places, since you'll be simply painting every pixel <x, y> ever occupies for 0<=t<=1. There are probably algorithms extant to smooth that behavior out and produce better "single-pixel-wide" lines.
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: creating a ellispse at any aspect angle

 
0
  #3
Oct 7th, 2004
Again, don't just blatantly post questions like this. Further posts of these nature (ie, you simply posting a question that looks like homework, but lacking any code you've written, will be closed, no questions asked.

We're here to help you learn, not to cheat.
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC