Hello.
This code help you. Sorry is not tested
The position is modelled in a user type with comments in spanish.
The angle between two positions is obtained with getAngulo()
The distance is obtained with getDistancia()
Bye,
Paposo
This code help you. Sorry is not tested
Type TPosicion Field posX:Float Field posY:Float ' Constructor Function create:TPosicion(x:Float, y:Float) Local p:TPosicion=New TPosicion p.posX=x p.posY=y Return p EndFunction ' Devuelve la distancia en linea recta hasta otra posicion Method getDistancia:Float(pos:TPosicion) Local x:Float=pos.posX-posX Local y:Float=pos.posY-posY Local retorno:Float=Sqr((x*x)+(y*y)) Return retorno EndMethod ' Devuelve el angulo que forma con otra posicion Method getAngulo:Float(pos:TPosicion) Local x:Float=(pos.posX-posX) Local y:Float=(pos.posY-posY) Local g:Float=ATan(Abs(y/x)) If(x<0 And y<0) g:+180 ElseIf (x<0) g=180-g ElseIf (y<0) g=360-g EndIf Return g EndMethod endtype
The position is modelled in a user type with comments in spanish.
The angle between two positions is obtained with getAngulo()
The distance is obtained with getDistancia()
Bye,
Paposo