Which equation should I use to plot the surface of a 3D egg shape?

조회 수: 3 (최근 30일)
I would like to know the parametric equation (in cartesian coordinates z=f(x, y)) to plot the surface of a 3D egg shape? Or do you know any matlab function that plots the surface of an egg (like ellipsoid, sphere or spherocylinder for the corresponding geometry)?

채택된 답변

Star Strider
Star Strider 2020년 10월 8일
It depends on how the shape is defined.
For this example, the surf or mesh function works, depending on what you want:
[X,Y,Z] = sphere(15);
Z = Z(:,1).*exp(0.5*Z(:,1)) + Z;
figure
surf(X,Z,Y)
axis('equal')
.
  댓글 수: 2
Martina Clairand
Martina Clairand 2020년 10월 12일
Great thank you!
But, why does it work? Why do we only transform the first column of Z?
can we use this new Z in the equation of a sphere: (X - a)² + (Y - b)² + (Z - c)² = r² ?
Thank you for your help!
Star Strider
Star Strider 2020년 10월 12일
As always, my pleasure!
The ‘Z’ assignment transforms all of the original ‘Z’. That line uses ‘automatic implicit expansion’ (introduced in R2016b) to add the transformed first column (since they are all the same) to the rest of ‘Z’.
You can plot essentially any shape that you can describe mathematically with this approach. I have created and plotted airplane wings using it.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by