11 Replies Latest reply on Dec 10, 2010 7:09 PM by marcelozep3

# [as2] Math Finding x, y point

Hi.

How would I find the x, y values here?

• ###### 1. Re: [as2] Math Finding x, y point

following set of points will lie on that triangle's hypoteneuse:

{x,3/4x}

where x varies from the left-most to right-most of the triangle.

• ###### 2. Re: [as2] Math Finding x, y point

Yes, thanks, but what would be the formula.

It can me made in pure math, not actionscript.

• ###### 3. Re: [as2] Math Finding x, y point

y=3/4x

• ###### 4. Re: [as2] Math Finding x, y point

point y= (triangle height/triangle width) * point x

Is that right?

• ###### 5. Re: [as2] Math Finding x, y point

what if the triangle is not a triangle rectangle?

• ###### 6. Re: [as2] Math Finding x, y point

you'll need to use trig if you're not using a "special" triangle.  how you'll do that depends on what's known about the triangle.  for example, do you know the length of all 3 sides?  do you know 2 angles and 1 side?  do you know 2 sides and 1 angle?

• ###### 7. Re: [as2] Math Finding x, y point

Could you write the formula?

I think it would be great

• ###### 8. Re: [as2] Math Finding x, y point

The following might help:

http://en.wikipedia.org/wiki/Law_of_cosines

http://en.wikipedia.org/wiki/Law_of_sines

http://en.wikipedia.org/wiki/Trigonometry

As kglad stated it depends upon which bits of the triangle you already know and which bits you are trying to find. But given that Flash is generally viewed through the x/y grid you can usually resolve things to a right triangle and use the basic identities. Most stuff in Flash requires only some basic trig and not the far more generic identities and equations.

What are you actually trying to do?

• ###### 9. Re: [as2] Math Finding x, y point

I´m trying to make this happens:

I´m trying to find the rotation value to add to the green movieclip hanged by the claw, so it rotates right and left a bit to give an idea of displacement, when the claw catches it.

It would be in a onEnterFrame method. I need to know what would be the rotation values to make it happen, to make the idea of displacement.

I think that´s hard isn´t it?

Thanks

• ###### 10. Re: [as2] Math Finding x, y point

Yeah, generally what you seem to be pursuing is going to be difficult. Especially if you don't have a lot of math skills.

I would probably recommend faking it. Just do some kind of damped rotational easing to make it look good. Unless you need something closer to physical reality it would probably be the best solution.

Otherwise you probably want to find some kind of prebuilt physics engine and use that.

http://ntt.cc/2008/03/20/the-list-of-as3-physics-engine-open-source-non-open-source.html

• ###### 11. Re: [as2] Math Finding x, y point

It´s ok, but I needed in actionscript 2.0.

I don´t mind doing the difficult way.

By the way, if I did it in the easy way, I would had to find the angle of equilibrium to rotate a bit right and left.

So, I don´t mind doing the difficult way.

Thanks