Drawing 3D surfaces like ellipsoid or sphere using regular grid

159 views
Skip to first unread message

Kushnir Yura

unread,
Oct 28, 2015, 7:44:46 AM10/28/15
to Jzy3d
Hi there, could anyone help me building surface like x^2/625 + y^2/64 + z^2 = 1?
As far as I know, x would be in range of -25; 25, y range would dynamically change depending on x, and I should create 2 shapes, one for z = Sqrt(1 - x^2/625 - y^2/81) and one for z = - Sqrt(1 - x^2/625 - y^2/81)
I tried doing something like this:
Mapper mapper = new Mapper() {
@Override
public double f(double x, double y) {
if (x < -25 || x > 25 || y < -getYRange(x) || y > getYRange(x))
return Float.NaN;
return  Math.sqrt(1.0f - (x*x)/625.0f - (y*y) / 64.0f);
}
};
Mapper mapper2 = new Mapper() {
@Override
public double f(double x, double y) {
if (x < -25 || x > 25 || y < -getYRange(x) || y > getYRange(x))
return Float.NaN;
return  -Math.sqrt(1.0f - (x*x)/625.0f - (y*y) / 64.0f);
}
};

getYRange(x) is a function that returns y range for each value of x.
However, after displaying the surfaces it seems like there is an empty space close to 0, therefore I can't get correct ellipsoid.
What should I do to make it correct?

Martin Pernollet

unread,
Oct 28, 2015, 1:18:42 PM10/28/15
to Jzy3d
Hi,

The (default) tesselator you use in the example you sent me will always use squares to make the surface :

Images intégrées 1
You need to change the polygons on the border of each of your two surfaces. You can find inspiration in the RingTesselator code (demo available in the developer guide). This tesselator "cut" squares when they cross a given radius to let them look as a ring border.

Images intégrées 2
 
Note however that this tesselator is made for circle shapes : you would need to derive it to consider your ellipsoid formula, otherwise it will look like below (see javadoc to understand how the algorithm works) : 

Images intégrées 3
I would love to see your ellipsoid in Jzy3d API :)

Regards,

Martin



--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "Jzy3d".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse jzy3d+un...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.

Kushnir Yura

unread,
Oct 28, 2015, 4:25:46 PM10/28/15
to jz...@googlegroups.com
Hello, thank you very much for response in such short notice.

I have 2 more questions for you

1) What about different 3d shapes like cone, hyperboloid, etc. Do I have to write tesselator for each one of them or would the default one work?
2) How can I plot 2d shapes like cylinder in 3d? For example, I have equation x^2+y^2=9. I know there is a shape of cylinder, but I wonder if that would be suitable for those kind of equations, considering that in general they would be in a form of x^2/a^2+y^2/b^2+z^2/c^2(optional) = D, where D belongs to a set of rational numbers

Best regards, Kushnir Yura.

--
Vous recevez ce message, car vous êtes abonné à un sujet dans le groupe Google Groupes "Jzy3d".
Pour vous désabonner de ce sujet, visitez le site https://groups.google.com/d/topic/jzy3d/f_GvguNEbuQ/unsubscribe.
Pour vous désabonner de ce groupe et de tous ses sujets, envoyez un e-mail à l'adresse jzy3d+un...@googlegroups.com.

Martin Pernollet

unread,
Oct 30, 2015, 4:22:56 AM10/30/15
to Jzy3d
You are welcome.

Existing tesselators assume mappers are z=f(x,y) with a single solution for z. Equation with more than one solution for z should be implemented differently. I think you need to write one tesselator for all equations of second order, one tesselator for equations of third order, etc, assuming N order equation all have a common way to be "traversed".
For N=2, I believe traversing space for Z>=0 and then Z<=0 is the generic way (but I am not sure, what do you think?), the tesselator should have a third step as I described earlier. 

If you send a collection of picture of x^2... equation in 3d I might think about it more in details.

Cylinder in jzy3d are built by defining radius and height, not by defining equations. That would be very very interesting to have such kind of mappers and tesselation in jzy3d. I encourage you to implement them, I would be happy help you about this.

Speaking about different ways of defining equations in jzy3d : you can have a look at the parametric equation package.

Images intégrées 1


Images intégrées 2

Images intégrées 3 
Reply all
Reply to author
Forward
0 new messages