tags:

views:

79

answers:

1

I have vector street map data in 2D format as below:

polyline0: dataX = {x00,x01,..,x0n} dataY = {y00,y01,..,y0n}

polyline1: dataX = {x10,x11,..,x1n} dataY = {y10,y11,..,y1n}

polyline2: dataX = {x20,x21,..,x2n} dataY = {y20,y21,..,y2n}

...

polylinem: dataX = {xm0,xm1,..,xmn} dataY = {ym0,ym1,..,ymn}

I can draw polyline0, polyline1,.., polylinem on screen as top down view (2D).

Now I want to draw polyline0, polyline1,.., polylinem on screen as 2.5D view (either perspective projection or isometric projection)

I am looking for algorithm to convert 2D coordinates to 2.5D. I tried to search for this algorithm on the internet but could not find.

What I am looking is just a simple formula that allow me to convert the above 2D data to 2.5D data as below:

take polyline0 as example: for (i = 0; i < n; i++) { dataX[i] in 2.5D = convert2Dto2.5D(dataX[i] in 2D); dataY[i] in 2.5D = convert2Dto2.5D(dataY[i] in 2D); }

I am looking for your help and greatly appreciated your time to help me with a algorithm to convert 2D coordinates to 2.5D.

+1  A: 

For the commenters, 2.5D is described here.

The isometric projection looks pretty straightforward to implement. The math becomes simpler with the restrictions you have.

The z coordinate of the points on the lines is always 0, so the product of the matrices on that wikipedia page is just

newx = 1 / sqrt(2) * oldx;
newy = 1 / sqrt(6) * (oldx + 2 * oldy);

or

newx = oldx;
newy = 1 / sqrt(3) * (oldx + 2 * oldy);

if you don't mind the scaling.

Other isometric views can be worked out from the source above.

UncleO
Thanks UncleO, I modified your formula a bit to make it work with integer: newx = 1000*oldx/1414; newy = 1000*(oldx + 2*oldy)/2449;
nguyen
newx = 1000*oldx/1414; newy = 1000*(oldx + 2*oldy)/2449;
nguyen
However, when I apply that formula, the result is not what I want. What I want is to convert 2D vector street map like this picture http://androinica-serve.s3.amazonaws.com/wp-content/uploads/2009/07/copilot_mapmodes_2dnextturn.png to 2.5D or 3D like this picture http://pocketnow.com/html/portal/news/0000010736//340x_scrobble.jpg
nguyen