Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

With Graphics3D[Sphere[{0,0,0},1]] I can render a uniform 3D sphere, but how can I render an ellipsoid? I would need to specify the rotation of the ellipsoid and the length of the main axes. And the method should be reasonable fast to display around 100 at once.

share|improve this question
related – gpap Oct 29 '13 at 16:25
Look up GeometricTransformation – Simon Woods Oct 29 '13 at 16:36
This uses ContourPlot3D: – KAI Oct 29 '13 at 16:56
There is also an Ellipsoid function in the MultivariateStatistics package that I used here, but it acts cranky at times... – R. M. Oct 29 '13 at 23:12

3 Answers 3

up vote 9 down vote accepted

You can modify this if you need to specify the rotation in different way etc. As Simon Woods has suggested, probabl the best way is to use GeometricTransformation.

 ellipsoid[a_, b_, center_?VectorQ, rotation_, around_?VectorQ] := Fold[
           {ScalingTransform[{a, b, b}],
            RotationTransform[rotation, around],

 ellipsoid @@@ Table[{x, x, 10 {x, x, x}, x, {x, x, x}} /. x :> RandomReal[]
                     , {111}] // Graphics3D // AbsoluteTiming

enter image description here

share|improve this answer
I had a slight wtf moment at all the x's - nice way to generate the data. – Simon Woods Oct 29 '13 at 21:15
@SimonWoods uff I was afraid I've missed something :) – Kuba Oct 29 '13 at 21:21
You can compose the transforms with Dot instead of Fold: TranslationTransform[center].RotationTransform[rotation, around].ScalingTransform[{a, b, b}]. Very nice, +1! – Michael E2 Oct 30 '13 at 0:15
@MichaelE2 Thanks ;) and yes Dot looks clear and is about 3% faster than Fold on my pc. – Kuba Oct 30 '13 at 3:17

Using Sphere with Scale and Rotate works too:

Graphics3D[Rotate[Scale[Sphere[], {5, 4, 2}, {0, 0, 0}], 60 Degree, {1, 2, 1}]]

enter image description here

The first triple is the scaling in the x,y,and z coordinates, the second triple is the translation, and the third triple is the axis about which to rotate. To generate a number of random ellipses:

x := RandomReal[];
Show[Table[Graphics3D[Rotate[Scale[Sphere[], {x, x, x}, {x i/6, x i/6, x i/6}], 
                      x, {x, x, x}], Boxed -> False], {i, 25}]]

enter image description here

share|improve this answer

Thought I would add after looking at this quite a bit later. The numbers you use to generate the random ellipsoid orientation is not truly random. You are missing a factor of pi/2 in the 4th argument in the table.

When generating the table use this instead to get truly random ellipsoids:

 ellipsoid @@@ Table[{x, x, 10 {x, x, x}, pi/2*x, {x, x, x}} /. x :> RandomReal[]
                     , {111}] // Graphics3D // AbsoluteTiming

All I added was a factor of pi in the 4th argument of ellipsoid in the table being generated. This will give you random radian values from 0 to pi/2.

share|improve this answer
It is random, just not over a whole available domain. But it does not matter because the topic is not about random at all and so isn't my answer. I mean, your point is valid but I would just add this as a comment. – Kuba Sep 25 at 7:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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