|
Calculating distance Dario Mirkovski from Macedonia, Former Yugoslav Republic [20 posts] |
15 year
|
Hello,
Was wondering what is the best module to be used in order to calculate the distance from the triangle to the ball.
Thank in advance.
program.robo
|
|
|
Kevin from Ireland [2 posts] |
15 year
|
I would also appreciate this information
|
|
|
Anonymous |
15 year
|
1. Enable the create blobs array in the blob_filter module. That will create a variable that contains all the COG's of all the remaining blobs in the image.
2. Use the Calculate_Distance module and select the first 4 blob array entries (which are assumed to be object1 and object2's cogs).
3. Display the results stored in my_distance
Note that you can also use the VBScript module to create the variable from the following euclidean distance formula.
blobs = getArrayVariable("BLOBS")
... check that blobs is an array and has at least 4 values and then
dx = blobs(0) - blobs(2)
dy = blobs(1) - blobs(3)
my_distance = sqrt((dx*dx)+(dy*dy))
which should get you the same results at the Calculate_Distance module.
See attached robofile.
STeven.
program.robo
|
|
|
Kevin from Ireland [2 posts] |
15 year
|
Excellent. thanks very much.
|
|