POV-Ray : Newsgroups : povray.advanced-users : How to model a cube in 2D? : Re: How to model a cube in 2D? Server Time
26 Sep 2024 17:44:46 EDT (-0400)
  Re: How to model a cube in 2D?  
From: Joshua English
Date: 24 Jan 2001 12:05:12
Message: <3A6F0B45.67DE794C@spiritone.com>
Peter Popov wrote:

> On Mon, 22 Jan 2001 05:29:37 -0800, Josh English
> <eng### [at] spiritonecom> wrote:
>
> >You will have eight coordinates for the eight vertices of the box, and I
> >would leave them in 3D until the very end. So image we have an array
> >containing those points, for each element of the array you have the
> >standard x, y, and z coordinates:
>
> >(From Johns Matrix page) To rotate a position p by y*theta
> >newp.x = cos(theta)*p.x - sin(theta)*p.z
> >newp.y = p.y
> >newp.z = sin(theta)*p.x + cos(theta)*p.z
> >p = newp
> >
> >Then do the conversions for the other rotations.
>
> That's exactly what I am doing, though in a RHS coor. system the signs
> are a bit different.

I'm not familiar with that coordinatge system. Is that a cylindrical or
spherical system?

>
>
> >As for lighting, I'd have to think about that a bit more. If each face
> >was going to get a flat shade of color, I'd probably take the average of
> >its four corners, and play with angles from light to the point and from
> >the camera to the point to judge what kind of shading to put there.
>
> I'd just take the plane formed by 3 of the points and calculate the
> angle between the normal and the camera ray. Lighting is not my main
> problem.
>
> I have some trouble with the 3D calculations but I'll see if John's
> page will help me solve them.
>
> However, I still don't have a clue how to proceed once I have the
> screen coordinates of the vertices. I have to start with a square and
> scale, rotate & tilt it to its deformed shape. It is possible since a
> cube face in orthographic projection will always be a parallelogram,
> but how?

Once you determine where the point is in 3D space, it has to be fitted to
the drawing plane. The method I was think of does everything in 3D as far as
placement, and then compresses it to the plane. Once it's in a 2D form, it
wouldn't need to be rotated again. That's what the draw.x and draw.y lines
were trying to do (Not that they were particularly accurate, but that's the
theory I was working with). The other issue I was thinking about was that in
3D, the origin is usually set at the center, but in 2D, the origin is usual
the upper left or lower left corner.

I know it seems to be the long way around, but I can't think of any way to
use 2D coords only  and mimic 3D shape.

Josh


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.