tags:

views:

59

answers:

2

Problem: I have to plot a simple 3D graph/diagram with x,y,z coordinates given for some points. My goal is to export this 3D diagramm to svg -> I will have to make a projection as svg is not (yet) able to handle 3D.

So my input is a 3D diagramm with x,y,z coordinates and the output is a 2D view reduced to x,y coordinates.

Does anyone know a (preferrable small) java lib like this one for javascript?

The projection might be just point3d to point2d. That is all I really need.

Thank you!

A: 

Have a look at JFreeChart. Have a look at Batik for saving it to SVG

Jeroen Rosenberg
Thank you, but it seems only to support 3d style no real 3d diagramms. For example: I need bars to be placed on the ground in the foreground, background, left or right. The "ground" has to be rotated in 3d space to provide a better overview to the user.
TMoo
A: 

If all you need is something simple then I might say just write it yourself. If you don't need to move the camera you can assume a lot of the calculations zero out, and you can just do the following to get the 2d coordinate for any 3d point:

rect2d.x = rect3d.x / rect3d.z;
rect2d.y = rect3d.y / rect3d.z;

Doing that you can just simple take all of the 3d points that make up your polygon, and use the 2d points as your SVG primitive. The tricky part you're going to have to deal with is hidden surface removal, but that's not too hard. Shading is going to be your real problem, but maybe you can play around with gradients to emulate light.

chubbard
Thank you. I should also be able to rotate the whole graph using another point of view/camera position. Shading is not important at the moment.
TMoo