[Back to MATH SWAG index]  [Back to Main SWAG index]  [Original]

> If I get  inspired, I will add simple perspective transform to these.
> There, got inspired. Made mistakes. Foley et al are not very good at
> tutoring perspective and I'm kinda ready to be done and post this.

>   line(round(x1)+200,round(y1)+200,
>        round(x2)+200,round(y2)+200);

try this for perspective (perspecitve is easy to calculate but hard to
explain... I worked it out with a pencil and paper using "similar
triangles, and a whole heap of other math I never thought I'd need, it
took me the best part of 30 minutes but when I saw how simple it really

 this code gives an approximation of perspective... it's pretty good
 when K is more than 3 times the size (maximum dimension) of the object

K is some constant... (any constant, about 3-10 times the size of the
object is good) (K is actually the displacement of the viewpoint down
the -Z axis. or something like) K=600 would be a good starting point


{ not computationally efficient but it shows how it works.
  Here's one that gives "real perspective"


[Back to MATH SWAG index]  [Back to Main SWAG index]  [Original]