It's a spring that
adjusts its length referring to the distance between the two orange boxes. It's a test for the targeting system of my
FGM-148 Javelin v1.0. I want to use scripts to steer the rocket into it's target in top-attack mode and I need the distance between target, rocket, and launcher. I don't know if this phunlet could be useful. If you want to use it you're free to do so.
Variables:
scene.my.x1
scene.my.y1
scene.my.x2
s-
cene.my.y2
scene.my.xRel
scene.my.yRel
If you delete the floor and fixate one box the spring slowly extends.
If you drag a box slowly the spring extends referring to the distance. The other box only starts to move if you drag fast enough.
- - - - - - - - - - - - - - -
Calculation method:
1)
detecting all coordinates
(
x1, y1, x2, y2)
2)
calculating the absolute value of the difference between x and y coordinates (relative coordinates) (they also could be negative but with absolute values it looks nicer
)
∆x = |x2 - x1| and
∆y = |y2 - y1|
3)
Pythagoras' theorem for calculating the length (L)
L = √(∆x² + ∆y²)