transforming a rectangle into a trapezoid

Started by
4 comments, last by capn_midnight 9 years, 6 months ago
sorry for the craptitude of the image. I have an image of a person, it's all in black, and the bounding box around him is a rectangle. The sun is meant to cast his shadow onto the ground, which transforms his bounding box into a trapezoid. Given the right transformations, if the bounding box is transformed properly, than the image of the man will be transformed properly. I know what the height of the trapezoid should be (along the center meridian), and I know what the width of the top and bottom of the trapezoid should be (the bottom is the same width as the original rectangle, let's say he can't jump, and the top is always wider than the bottom). These things I can calculate quite easily using similar triangles. Given: width of image W, height of image H, minimum width of trapezoid W (same as width of image), maximum width of trapezoid W', height of trapezoid H' Solve: Create a matrix transform from the rectangle to the trapezoid I keep getting a matrix of the form

yc  0   0
0   d   0
0   0   1
with d = H'/H and c = W'/WH the problem is that y in the matrix. I would have to recalculate the matrix for each value of y. I've been bouncing around on this problem for the past 2 hours. Prithee, be so kind and lend a hand?

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

Advertisement
Ah, this is a projection problem, ive never done it before so i really cant help you, but maybe telling you its about projection might help... sorry im not good for much more than that lol
-Dan
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
Are you sure it's a trapezoid? If you're modeling your sun as a directional light, then the projection would also be rectangular.

Quote:Original post by Zipster
Are you sure it's a trapezoid? If you're modeling your sun as a directional light, then the projection would also be rectangular.

yes, a directional light would result in a rectangular projection.

hmm... I had been calculating with the sun as a point light source. The reason was because a directional light would only cast shadows in one direction. If I'm facing a sunset, and I see objects to the left and right of the sun in my field of vision, then the shadows will be cast in different directions. oh freaking bollocks, that's just because of the perspective projection of the direction I'm facing. The two shadows could be completely parallel and would still have that same effect from the fact that I'm standing in between them.

Alrighty, directional light it is, and a much simpler calculation. Thanks.

Sweet, that makes it so much easier now. I don't even have to calculate W', just H'.

edit: bolded portion is a train of thought that I feel, even though it is flawed in it's conclusion, should remain to demonstrate the thought process to viewers.

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

1 0 0 0

0 1 0 1

0 0 1 0

0 1 0 0

y_= 0*x + 1*y + 0*z +1*w

w_= 0*x + 1*y + 0*z +0*w

y(screen)=y_/w_ = y*w/y = w =1

www.comp.nus.edu.sg/~tants/tsm/TSM_recipe.html

Wow, you realize this thread is 10 years old?

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

This topic is closed to new replies.

Advertisement