Forum Topic: whats that code

(126 views • 12 replies)

This topic is 1 page long.

<< < > >>
None

piggy123

Reply To Post Reply & Quote

Posted at: 8/1/09 12:11 PM

piggy123 NEUTRAL LEVEL 14

Sign-Up: 06/13/08

Posts: 925

whats hat as2 code where if they get in a certin radies of a guy something happens?


None

Paranoia

Reply To Post Reply & Quote

Posted at: 8/1/09 12:19 PM

Paranoia DARK LEVEL 34

Sign-Up: 04/22/05

Posts: 9,697

It's determined via Pythagoras:

distance * distance = x * x + y * y;
BBS Signature

None

piggy123

Reply To Post Reply & Quote

Posted at: 8/1/09 12:30 PM

piggy123 NEUTRAL LEVEL 14

Sign-Up: 06/13/08

Posts: 925

where do i fill in the radies though?


None

UnknownFury

Reply To Post Reply & Quote

Posted at: 8/1/09 12:34 PM

UnknownFury EVIL LEVEL 26

Sign-Up: 08/10/05

Posts: 6,031

At 8/1/09 12:19 PM, Paranoia wrote: It's determined via Pythagoras:

distance * distance = x * x + y * y;

Get the x distance and y distance and add the squares and compare it to the sum of the radii squared.

radii = (r1 + r2) * (r1 + r2)

xd = x1 - x2
yd = y1 - y2
d = xd * xd + yd * yd

if(d < radii) ...

Portfolio(Under construction): UnknownFury.com |
Msn: giant_ak_47@msn.com | Contact: me@unknownfury.com
Follow me on twitter!


Misunderstood

piggy123

Reply To Post Reply & Quote

Posted at: 8/1/09 12:38 PM

piggy123 NEUTRAL LEVEL 14

Sign-Up: 06/13/08

Posts: 925

i admit it i suck at math but here is the guys radies

x = 260.6 y = 197.1


None

piggy123

Reply To Post Reply & Quote

Posted at: 8/1/09 12:56 PM

piggy123 NEUTRAL LEVEL 14

Sign-Up: 06/13/08

Posts: 925


None

Anamethatworks

Reply To Post Reply & Quote

Posted at: 8/1/09 01:05 PM

Anamethatworks NEUTRAL LEVEL 03

Sign-Up: 05/17/09

Posts: 82

perhaps it would be easier if you draw/do the problem on paper first.

you're problem right now is that you know the x line and y line of a triangle between the two points (absolute difference between x1 and x2 = x line, same with y)
so you know two sides of a triangle of which one angle is 90 degrees.
all you need to do now is calculate the hypotenuse (diagonal side)

which as stated earlier is easy using
a^2 + b^2 = c^2 (xline^2 + yline^2 = hypotenuse^2)
here's a picture from wikipedia

so after that just get the square root of c and there you go, the length of the hypotenuse which is the distance between the two points

(in case you don't quite get which point is which, corner a c is the coordinates of 1 point, a b is were xline and yline meet, and b c is the coordinates of your second point)


Resigned

piggy123

Reply To Post Reply & Quote

Posted at: 8/1/09 01:12 PM

piggy123 NEUTRAL LEVEL 14

Sign-Up: 06/13/08

Posts: 925

what did you just say?


None

UnknownFury

Reply To Post Reply & Quote

Posted at: 8/1/09 01:15 PM

UnknownFury EVIL LEVEL 26

Sign-Up: 08/10/05

Posts: 6,031

The radius of a circle is the width or height (they should be the same) divided by 2. If you just want to do an approximate with a bounding circle of a non circular object then take whichever is greater height or width and treat that as your diameter.

Also be patient. You didn't want any time at all for an answer.

At 8/1/09 01:05 PM, Anamethatworks wrote: so after that just get the square root of c

It probably doesn't matter as far as this is concerned, but it's much faster to compare the radii squared than it is to square root the distance and compare to the sum of the radii. Squaring takes a fraction of the time square rooting does.

Portfolio(Under construction): UnknownFury.com |
Msn: giant_ak_47@msn.com | Contact: me@unknownfury.com
Follow me on twitter!


None

Anamethatworks

Reply To Post Reply & Quote

Posted at: 8/1/09 01:37 PM

Anamethatworks NEUTRAL LEVEL 03

Sign-Up: 05/17/09

Posts: 82

true its faster to do it like that, but the point is understanding the math behind the Pythagorean theorem.
And to get the actual distance you need to know c and not c^2
here's a picture explaining what I said in the other post... again it looks awful I know.. just made it in paint a few seconds ago


None

AnalogStick

Reply To Post Reply & Quote

Posted at: 8/1/09 01:48 PM

AnalogStick LIGHT LEVEL 07

Sign-Up: 10/13/06

Posts: 944

Makes you wonder what they teach kids these days if they don't know basic things like Pythagoras theorem.


Shouting

Anamethatworks

Reply To Post Reply & Quote

Posted at: 8/1/09 02:15 PM

Anamethatworks NEUTRAL LEVEL 03

Sign-Up: 05/17/09

Posts: 82

yeah no kidding, it's one of the most basic things ever.
and you can't really do much without it.

kinda sad really


None

hoboguise

Reply To Post Reply & Quote

Posted at: 8/1/09 02:22 PM

hoboguise EVIL LEVEL 08

Sign-Up: 04/21/09

Posts: 73

wow, im a teen myself but i found this thread amusing with a kid who doesnt understand how pythagoras works, some advice to piggy123 is not to attempt any physics at all if he doesnt even understand how pythagoras theorum work, i wonder if he's been taught about |sin|cos|tan|

Hobo guise Current Projects:
Plane shooter being programmed by rishabh005 Self programmed agent game. Also a dragon drawing for some reason.

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 08:54 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!