# Plotting ellipse with given parameters

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

• Graphics[GeometricTransformation[Ellipsoid[center, {major, minor}], RotationTransform[angle, center]]?
– kglr
Jun 24, 2021 at 0:29

## 2 Answers

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}],}]


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}]]


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]