Take the 2-minute tour ×
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
2  
Look up GeometricTransformation –  Simon Woods Oct 29 '13 at 16:36
    
This uses ContourPlot3D: demonstrations.wolfram.com/Ellipsoid –  KAI Oct 29 '13 at 16:56
1  
There is also an Ellipsoid function in the MultivariateStatistics package that I used here, but it acts cranky at times... –  rm -rf Oct 29 '13 at 23:12

2 Answers 2

up vote 7 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[
           GeometricTransformation,
           Sphere[],
           {ScalingTransform[{a, b, b}],
            RotationTransform[rotation, around],
            TranslationTransform[center]}]

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

enter image description here

share|improve this answer
1  
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
1  
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

Your Answer

 
discard

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.