 1. Distance Meter

ciao.
I would like to add a counter that measures the distance reached by a ball thrown
How can I do?
There is specific meted ?
Alex  Reply With Quote

2. Re: Distance Meter

It's prety easy ^^, jsut store the X, Y original position and do mathematics : Sqr((xB-xA)²+(yB-yA)²)

xA and yA are originals positions
xB and yB are positions of your ball  Reply With Quote

3. Re: Distance Meter

Just for information, the formula provided by Pgm_snipe is Pythagoras' theorum, also known as the "distance formula". What you are calculating is the "hypotenuse" of a triangle where the length of the two sides you know are opposite and adjacent to the hypotenuse.

It's worth having read so that formulae like this are understood.  Reply With Quote

4. Re: Distance Meter

ops....can you explain me how to put it step by step....

i don't understand "just store the X, Y original position and do mathematics : Sqr((xB-xA)²+(yB-yA)²)"

grazie  Reply With Quote

5. Re: Distance Meter

xA is the original X
yA is the original Y

xB is the target x
yB is the target y

So if the start position of the ball is 80,90 and the end position is 100,150, the distance between those two points is calculated as follows:

Sqr((100-80)² + (150-90)²)

or

Sqr((100-80)*(100-80) + (150-90)*(150-90))

The Sqr function calculates the square root of the calculation in the outside brackets.

Watch the video at the link below and consider that you know the lengths a and b because you know the coordinates of the points at the end of lines a and b. You then use Pythagoras' theorum to calculate C which is the distance between the start and end points of your ball.

http://www.pythagorastheorem.co.uk/  Reply With Quote

6. Re: Distance Meter

i don't think it is right....
please check it : example  Reply With Quote

7. Re: Distance Meter Originally Posted by videogiochi
i don't think it is right
You don't think what is right?

Can you explain where the problem lies before I download your file?  Reply With Quote

8. Re: Distance Meter

I did a test file.
I just wanted to know if it was good ....  Reply With Quote

9. Re: Distance Meter Originally Posted by videogiochi
I did a test file.
I just wanted to know if it was good ....
You said you didn't think it was right; was there anything in particular?

When learning something like this, it is best to set up a test system. e.g. create two objects where you know the distance between them, then use your formula to check the results. That way, you don't need to upload files for other people to check unless you have a specific problem that you can't fix and need help with, in which case, you can state the problem, explain the tests that you have carried out, and then someone else can have a look in order to help you.  Reply With Quote

10. Re: Distance Meter

ok, I'm sorry.
Now remove the file from my ftp.
thanks for your support
Alex  Reply With Quote Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•