Rotation of Elipse axes from covariance matrix

  • Thread starter yakerdude7
  • Start date
Im writing some java code and need help with some matrix math... :confused:

Basically Im trying to figure out how to rotate an ellipse given the std deviations, means, and covariance matrix such that the major and minor axes are along the direction that has the greatest variance. This is just a 2D ellipse, so my covariance matrix is 2x2. I know I need the eigenvectors of the covariance matrix to rotate the ellipse and the eigenvalues to scale the rotated ellipse, but Im confused in the details. Here is my basic idea:
1. Shift ellipse to origin
2. Scale ellipse
3. Rotate ellipse
4. Shift ellipse back

I remember from long time ago that you usually apply transformations, then unapply them (using the inverse), but I dont want to unrotate or unscale here do I?

Also, I am using the AffineTransform class in java, so I have to pass in a 3x3 transformation matrix. How do I get from my 2x2 covariance matrix and 2x2 eigenvectors/eigenvalues into the 3x3 form? By 3x3 I mean:
cos(theta) sin(theta) 0
-sin(theta) cos(theta) 0
0 0 1
(for a rotation matrix)
 
Last edited by a moderator:

fresh_42

Mentor
Insights Author
2018 Award
11,113
7,640
You should write down every single step in terms of a matrix multiplication in case of a linear transformation, and a vector addition in terms of a shift. You can then finally calculate the overall transformation necessary to transform your ellipse.
 

Want to reply to this thread?

"Rotation of Elipse axes from covariance matrix" You must log in or register to reply here.

Related Threads for: Rotation of Elipse axes from covariance matrix

Replies
11
Views
3K
Replies
0
Views
1K
  • Posted
Replies
7
Views
2K
Replies
2
Views
12K
  • Posted
Replies
10
Views
5K

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top