Rotation of Elipse axes from covariance matrix

Click For Summary
SUMMARY

The discussion focuses on rotating a 2D ellipse using a covariance matrix in Java. The user aims to align the ellipse's major and minor axes with the directions of greatest variance, utilizing the eigenvectors and eigenvalues derived from the covariance matrix. The process involves shifting the ellipse to the origin, scaling it based on the eigenvalues, and then rotating it using a 3x3 transformation matrix. The AffineTransform class in Java is employed to implement these transformations, requiring conversion from a 2x2 covariance matrix to a 3x3 rotation matrix.

PREREQUISITES
  • Understanding of 2D ellipse geometry
  • Knowledge of covariance matrices and their properties
  • Familiarity with eigenvalues and eigenvectors
  • Experience with Java's AffineTransform class
NEXT STEPS
  • Learn how to compute eigenvalues and eigenvectors of a 2x2 matrix
  • Study the process of transforming shapes using matrix multiplication
  • Explore Java's AffineTransform class documentation for advanced transformations
  • Investigate the application of covariance matrices in data analysis and statistics
USEFUL FOR

Mathematicians, data scientists, and Java developers working on graphical applications or statistical modeling that require geometric transformations of shapes based on variance analysis.

yakerdude7
Messages
1
Reaction score
0
Im writing some java code and need help with some matrix math... :confused:

Basically I am 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 I am 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 don't 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:
Physics news on Phys.org
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.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 7 ·
Replies
7
Views
3K
Replies
27
Views
5K
  • · Replies 12 ·
Replies
12
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 22 ·
Replies
22
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 12 ·
Replies
12
Views
3K