We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › finding right edge of an angled image
Page Index Toggle Pages: 1
finding right edge of an angled image (Read 476 times)
finding right edge of an angled image
Sep 30th, 2007, 3:33am
 

Hi
I am having trouble tracking the right hand edge of an image.
I am making many pictures of arrows fly across the screen and want to find when they hit the right hand edge so I can make them stop. Each image is given a random rotation.

http://www.dement.org/moving_forest/problem/arrows10.html

I am using the calculation
cos(angleInRadians) x widthOfImage
to find the actual width now that the image is rotated. I add that to the current x position to find the current right edge.

I am not getting the right numbers at all and can't work out why not.  If you run this you'll see that the arrows angled down fall short of the edge and the arrows angled up go too far.

Any help would be much appreciated.

thanks
trigonometrically challenged
Linda
Re: finding right edge of an angled image
Reply #1 - Oct 1st, 2007, 3:48pm
 
Hi Linda,

When you draw a picture using image(PImage, x, y), the upper-right corner of your picture is at (x, 0).

Your right-edge formula is correct but according to this statement, it gives you the x-position of the upper-right corner of your picture.

Maybe you should try to draw your arrows vertically-centered to solve your problem.

Nicolas.
Re: finding right edge of an angled image
Reply #2 - Oct 2nd, 2007, 3:09am
 
Thanks Nicholas
I'll give that a try.
Linda
Page Index Toggle Pages: 1