Image:
 Author: credencial Group: Lesson Filesize: 10.01 kB Date added: 2022-04-24 Rating: 5 Downloads: 113 Views: 116 Comments: 0 Ratings: 1 Times favored: 0 Made with: Algodoo v2.1.0 Tags:
|
Step by step:
1) Create the variables in the console: scene.my.poslaser := [] and scene.my.geopos := []
2) In the laser object onLaserHit = (e)=>{scene.my.geopos = e.geom.pos}
3) On laser object postStep = (e)=>{scene.my.poslaser = e.this.pos}
4) On the object to be measured at reflectiveness = 0 and reflectiveIndex = 0.
5) In the text box text={
"Pythagorean distance: " + math.sqrt(((scene.my.poslaser(0) - scene.my.geopos(0)) ^ 2) + ((scene.my.poslaser(1) - scene.my.geopos (1)) ^ 2)) + "\
Round: " + math.toint(math.sqrt(((scene.my.poslaser(0) - scene.my.geopos(0)) ^ 2) + ((scene .my.poslaser(1) - scene.my.geopos(1)) ^ 2))) + " meters"
}
6) You can select all geometries to change position and check the calculation. |