2D plane -> 3D hemisphere with trig?

2D plane -> 3D hemisphere with trig?

Post by Gil Murra » Mon, 04 Aug 1997 04:00:00



Hi,

I'm looking for a way to take a flat surface and transform it into a
pseudo 3D hemisphere.

I've trying to apply trig functions to every point in the bitmap to
achieve this but can't quite get the formula right. The result is always
a king of 3D octagon rather than a hemisphere. I'm hoping that someone
may be able to tell me where I'm going wrong....

The source points are mapped to a cartesian plane (where the x and y
axis divide the bitmap into four quarters), then each point gets the
following treatment:

                double dAngle = atan2(y, x);                 // [=
atan(y/x)]

                double dNewX = x * cos(dAngle);
                double dNewY = y * sin(dAngle);

The new point is then mapped back to pixel coordinates and displayed on
screen.

This bit of code moves the point from its original position towards the
origin. Points at the corners of the bitmap move quite far; points near
the origin or the axis hardly move at all.

The "octagon" I get is pretty close to a hemisphere. I feel I'm *almost*
there, but my maths is so rusty I can't see what to try next. Maybe I
need to modify the x and y in the two lines above, but how?

If anyone can help I'd be grateful.

Cheers,

    Gil

 
 
 

2D plane -> 3D hemisphere with trig?

Post by Gil Murra » Mon, 04 Aug 1997 04:00:00


Hi,

I'm looking for a way to take a flat surface and transform it into a
pseudo 3D hemisphere.

I've trying to apply trig functions to every point in the bitmap to
achieve this but can't quite get the formula right. The result is always
a king of 3D octagon rather than a hemisphere. I'm hoping that someone
may be able to tell me where I'm going wrong....

The source points are mapped to a cartesian plane (where the x and y
axis divide the bitmap into four quarters), then each point gets the
following treatment:

                double dAngle = atan2(y, x);                 // [=
atan(y/x)]

                double dNewX = x * cos(dAngle);
                double dNewY = y * sin(dAngle);

The new point is then mapped back to pixel coordinates and displayed on
screen.

This bit of code moves the point from its original position towards the
origin. Points at the corners of the bitmap move quite far; points near
the origin or the axis hardly move at all.

The "octagon" I get is pretty close to a hemisphere. I feel I'm *almost*
there, but my maths is so rusty I can't see what to try next. Maybe I
need to modify the x and y in the two lines above, but how?

If anyone can help I'd be grateful.

Cheers,

    Gil

 
 
 

1. 2D trig question

I'd appreciate a little help with this 2D trig problem. See diagram
here:

www.ai-junkie.com/occluded_segment.jpg

Given points A, B, C, D and radius r, what's the best (read fastest)
way to calculate points p1 and p2?

thanks

2. {{ sNaTcH }}

3. 3d Cad>>3D Animations>>3D Models

4. Did someone say MERGER?

5. Determining a 3d point is on a 3d hemisphere

6. 3DStudio & Win95

7. 3D trig to line up halos?

8. HELP

9. 2D->3D?

10. Converter from 3D images -> 2D hidden images

11. 3D > 2D slices

12. 2D -> 3D image reconstruction

13. 2D TIFF->3D