• 12
• 12
• 9
• 10
• 13

# transforming a rectangle into a trapezoid

This topic is 1254 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 1254 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.
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.42523014545440674, "perplexity": 905.4538343439058}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 5, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2018-13/segments/1521257647671.73/warc/CC-MAIN-20180321160816-20180321180816-00400.warc.gz"}