# transforming a rectangle into a trapezoid

This topic is 1371 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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?

##### Share on other sites
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

##### Share on other sites
Are you sure it's a trapezoid? If you're modeling your sun as a directional light, then the projection would also be rectangular.

##### Share on other sites
Quote:
 Original post by ZipsterAre 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.

##### Share on other sites

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

Edited by docwho

##### Share on other sites

Wow, you realize this thread is 10 years old?

##### Share on other sites

This topic is 1371 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

This topic is now closed to further replies.

1. 1
2. 2
Rutin
20
3. 3
JoeJ
17
4. 4
5. 5

• 37
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631704
• Total Posts
3001822
×