Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Calculating angle of circle to produce given ellipse

  1. Aug 2, 2012 #1
    I know I should keeps this short, but I need to explain it a little. So, please have patience with me :)

    Given a standard ellipse, and its eccentricity and position on screen, is there some clever way of calculating how much a regular circle needs to be tilted in (angles) in a perspective view to produce said ellipse? Obviously the tilt is related to the position on screen, as the very act of moving a circle around, will change the ellipse. So it's not so much a tilt in world space I need to calculate, as it is the angle between a ray going from the center of the circle to the camera, and the normal of the circle (I'm not sure if the normal of a circle is the right term when speaking of a 2D object, but think of the cap of a cylinder instead, then you know what I mean by the normal from the center of the cap).

    I have tried for a long time now, by using a purely trigonomical approach, but even though my results aren't way off, they aren't precise either. And the closer to camera the circle is, the less precise my method is. It's surele because my approach considers the view orthogonal ;)

    I have the angular separation of the two maximum distances (on the semi-major axis, or more plainly, the total width of the ellipse), calculated from the cameras field of view, and the screen seperation of said points, and the center position of the ellipse on screen, which my intuition tells me I need, in order to calculate this. I also have the perspective transformation matrix of the camera. I just can't find the right approach. The ellipse are in no way alligned with the view axis, it can be rotated.

    This thread, which I posted some weeks ago, gave me a great solution to a related problem, but this was before I had the ellipse. And even though the math I was offered back then in theory would be what I need to solve this with the ellipse, it is WAY too affected by even the smallest inaccuracies of the center direction. It only works on perfect data. This is why I came up with this elliptic approach instead, where the ratio between the semi major/-minor axis should be A LOT less affected by inaccuracies, and the calculated angle should be more precise, even when data is noisy.

    Sorry for the long story. Please, if anybody can push me onwards, I would be grateful! And if not, I'm sure it's for a good reason ;)
     
  2. jcsd
  3. Aug 4, 2012 #2
    Hi,

    I find it hard to answer your question as I found the geometry of your problem is not explained clearly. You spoke about "perspective transformation matrix of the camera". Is your problem related in any way to camera calibration with dot array calibration pattern?
     
  4. Aug 4, 2012 #3
    It all goes on in a game engine, so the camera has perspective transformation matrix defined. And no, this is not for calibrating, this is just as explained ;)

    1) I have an ellipse.
    2) This ellipse has a major and minor semi axis. The max points of these two axis are defined. The axis rotation on screen is also defined.
    3) The world angle from the camera through each of these points are defined

    I need to find a method of calculating the angular tilt of a circle, which would produce such an ellipse on that exact location on screen.

    But..Hold on with trying to answer me, I may have found a solution myself. Or at least a work around.
     
  5. Aug 4, 2012 #4

    HallsofIvy

    User Avatar
    Staff Emeritus
    Science Advisor

    Drawing a picture should help you. If the plane of the circle makes angle [itex]\theta[/itex] with the screen on which you are projecting, you have a line of length 2r (representing the circle of radius r) forming the hypotenuse of a right triangle with angle [itex]\theta[/itex] and base leg, the projection, of length [itex]2r cos(\theta)[/itex]. That is, a circle with radius r, [itex]x^2+ y^2= r^2[/itex], at angle [itex]\theta[/itex] projects to an ellipse with major semi-axis of length r and minor semiaxis of length [itex]r cos(\theta)[/itex]. Its equation would be [itex]x^2/r^2+ y^2/(r^2 cos^2(\theta))= 1[/itex].
     
  6. Aug 4, 2012 #5
    Thanks for the answer! I just did some pictures to visualize a problem with your solution. Unless I misunderstand.

    The semi-major axis, or the vectors pointing towards them, doesn't represent the diameter of the circle. If I calculate at what distance I have a circle radius between one of the max points on the semi major axis, and the center of the ellipse, I will calculate a distance too short, because the angle is a little too wide. As the circle rotates aways from you, the semi major axis, if projected onto the circle in world space, will lie between the two tangent points of the circle (or ellipse) as seen from above, which intersects the camera. And as I don't know the distance to the camera, I can't calculate those two points. And I can't calculate the distance without them either. Or maybe I can. I'm simply not skilled enough ;)

    TopDownEllipse.jpg

    SideViewEllipse.jpg

    My next approach is to drop the semi major axis max points all together, and instead find the actual points on the ellipse, which represents the diameter of the circle. This should be fairly easy. I know the circle center on screen. I know the center of the ellipse. The distance between those two could be used as my y-value, and then the x-value should be calculated. That would give me two points on the ellipse, which, if I shoot vectors at them, and measure the angle, could give me the distance to the circle center. When that is done, I'll look into your solution! It looks valid from then on.

    EDIT: The pics doesn't show up as pictures, even though they're wrapped in IMG tags. Last time I used those tags, it worked fine. I have no clue as to why this doesn't work. Sorry. Here they are as attachments as well.
     

    Attached Files:

    Last edited: Aug 4, 2012
  7. Feb 18, 2014 #6
  8. Jan 26, 2015 #7
    Hi,

    I have a problem which is quite similar: if you take a picture of a circle with a known radius, depending on the angle of view, the circle will become an ellipse on the picture. The semi-major axis of this ellipse will have the same length as the radius of the original circle. How do you prove it without making the orthographic projection assumption only valid at infinite distance between the camera and the circle (as made in the link above)?

    Cheers.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook