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:45:47 EDT (-0400)
  Re: How to model a cube in 2D?  
From: Josh English
Date: 22 Jan 2001 08:29:39
Message: <3A6C35C1.39A3F238@spiritone.com>
Since you are using an orthographic camera, you need to decide what the
image bounds are. The standard up y and right 4/3*x will mean that this
box will be outside the image plane. That's a problem for later, however.
The big trick is setting up a formula that takes the 3d points and
rotates them. YOu might not have a matrix command available, but that's
exactly what you need to look at for this. You can't use the matrix, but
you can use each row of the matrix in new declarations.

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.

Once you've done that you need to worry abount converting it to the
coords of the 2d image plane on a point we'll label drawp. The simplest
rule is to ignore the z coordinate:
drawp(p).x = p.x
drawp(p).y = p.y
I beleive that an orthographic camera may use that, but It's 5:30 as I
write this and I've only had two cups of coffee.

Another method might be to add the z coordinate
drawp(p).x = p.x + p.z   or  p.x + (1/3)*p.z
drawp(p).y = p.y + p.z   or p.y + (2/3)*p.z

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.

Josh
Peter Popov wrote:

> This will feel... a little strange.
>
> Imagine a scene like this:
>
> box { -1, 1 pigment { rgb 1 } rotate 60*y rotate -30*x}
> camera { location -5*z look_at 0 orthographic }
> light_source { <100,100,-100> color rgb 1 }
>
> Now imagine I want to make it in a 2D program, for example Corel Draw
> or Adobe illustrator. I want to start with a square for each face and
> calculate
>
> a) the necessary sequence of rotate and scale commands
> b) the amount of light falling on it (flat shading) if the light
> source position is known
>
> Can anyone help me with the math involved? Remember, I only have
> scale, rotate and tilt at my disposure, no matrices :(
>
> BTW the amounts of rotation along the y and x axes are arbitrary.
>
> Peter Popov ICQ : 15002700
> Personal e-mail : pet### [at] vipbg
> TAG      e-mail : pet### [at] tagpovrayorg

--
Josh English -- Lexiphanic Lethomaniac
eng### [at] spiritonecom
The POV-Ray Cyclopedia http://www.spiritone.com/~english/cyclopedia/


Post a reply to this message

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