4
$\begingroup$

How would I go about plotting an ellipse at a given center point x,y with a given angle, semi major axis length as well as the major axis length?

My attempt

I had tried to use the Ellipsoid function however for some reason it does not take or use the the axis lengths

Thanks for your help

$\endgroup$
1
  • 1
    $\begingroup$ Graphics[GeometricTransformation[Ellipsoid[center, {major, minor}], RotationTransform[angle, center]]? $\endgroup$ – kglr Jun 24 at 0:29
3
$\begingroup$
ClearAll[ellipsoid]
ellipsoid[center_, {majorradius_, minorradius_}, angle_] :=  GeometricTransformation[
  Ellipsoid[center, {majorradius, minorradius}], RotationTransform[angle, center]]

Examples:

Graphics[{EdgeForm[{Thick, Blue}], Opacity[.75], LightBlue, 
  ellipsoid[{0, 0}, {2, 1}, Pi/3],  Opacity[1], Red, Point[{0, 0}],}]

enter image description here

SeedRandom[1];
centers = RandomReal[50, {50, 2}];
radii = RandomReal[{1, 5}, {50, 2}];
angles = RandomReal[{0, 2 Pi}, 50];
colors = RandomColor[50];

Graphics[{EdgeForm[{Thick, #}], 
  Opacity[.75], #, ellipsoid@##2, Opacity[1], Black, Point@#2} & @@@
  Transpose[{colors, centers, radii, angles}]]

enter image description here

$\endgroup$
2
$\begingroup$

We can also use the second form of Ellipsoid Ellipsoid[p,Σ]

$$\left\{x\in \mathbb{R}^3|(x-p).{\Sigma^{-1} }.(x-p)\leq 1\right\}$$

For a,b,θ we set Σ as

Transpose@RotationMatrix[-θ].DiagonalMatrix[{a, b}]^2.RotationMatrix[-θ]
p = {3, 2}; a = 5; b = 2; θ = π/4;
Σ = 
  Transpose@RotationMatrix[-θ] . DiagonalMatrix[{a, b}]^2 . 
   RotationMatrix[-θ];
Graphics[{{Red, Ellipsoid[p, {a, b}]}, {Opacity[.5], EdgeForm[Cyan], 
   Yellow, Ellipsoid[p, Σ]}, {PointSize[Large], 
   Point[p]}}, Frame -> True]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.