class GLOBAL
types
public Altitude = real;
public FOId = token;
public RadarId = token;
public
Coordinates ::
X : real
Y : real;
public Time = nat;
public String = seq of char;
public ObstacleType = <Natural> | <Artificial> | <Airport> | <Military_Area>;
public FOWarning = ObstacleType | <EstimationWarning>;
public RadarWarning = <Saturated>;
public MinimumSafetyAltitude = nat | <NotAllowed>;
public Position ::
coord : Coordinates
altitude : Altitude;
public History = seq of Position;
public Vector ::
X : real
Y : real;
functions
protected isPointInRange : Coordinates * nat1 * Coordinates -> bool
isPointInRange(center,range,point) ==
(center.X - point.X)**2 + (center.Y - point.Y)**2 <= range**2;
protected vectorSum : Vector * Vector -> Vector
vectorSum(v1,v2) ==
mk_Vector(v1.X + v2.X,v1.Y + v2.Y);
protected vectorDiv : Vector * int -> Vector
vectorDiv(v,n) ==
mk_Vector(v.X/n,v.Y/n)
pre n <> 0;
protected addVectorToPoint : Vector * Position -> Coordinates
addVectorToPoint(v,p) ==
mk_Coordinates(p.coord.X + v.X, p.coord.Y + v.Y);
protected vectorLength : Vector -> real
vectorLength(v) ==
MATH`sqrt(v.X**2 + v.Y**2);
protected unitVector : Vector -> Vector
unitVector(v) ==
let l = vectorLength(v)
in
mk_Vector(v.X/l,v.Y/l);
protected dotProduct : Vector * Vector -> real
dotProduct(v1,v2) ==
v1.X * v2.X + v1.Y * v2.Y;
protected angleBetweenVectors : Vector * Vector -> real
angleBetweenVectors(v1,v2) ==
let uv1 = unitVector(v1),
uv2 = unitVector(v2),
dvs = dotProduct(uv1,uv2),
angle = MATH`acos(dvs)
in
radians2degree(angle);
protected radians2degree : real -> real
radians2degree(r) ==
r * (180/MATH`pi);
protected atan2 : real * real -> real
atan2(y,x) ==
2 * MATH`atan(y/(MATH`sqrt(x**2+y**2)+x))
pre not (x = 0 and y = 0);
protected signedVectorAngle : Vector * Vector -> real
signedVectorAngle(v1,v2) ==
atan2(v2.Y,v2.X) - atan2(v1.Y,v1.X);
protected vectorAngle : Vector -> real * real
vectorAngle(v) ==
mk_( radians2degree (MATH`acos(v.X / MATH`sqrt(v.X**2 + v.Y**2))),
radians2degree( MATH`asin(v.Y / MATH`sqrt(v.X**2 + v.Y**2))));
protected vectorRotate : Vector * real -> Vector
vectorRotate(v,a) ==
let x' = MATH`cos(a)*v.X - MATH`sin(a)*v.Y,
y' = MATH`cos(a)*v.Y + MATH`sin(a)*v.X
in
mk_Vector(round(x'),round(y'));
protected round : real -> real
round(r) ==
let fr = floor(r),
dif = abs(r - fr)
in
if(dif < 10**-10)
then fr
else r;
operations
public test : real * real * real * real ==>
Vector * Vector * real * real * Vector * real * real
test(x1,y1,x2,y2) ==
let v1 = mk_Vector(x1,y1),
v2 = mk_Vector(x2,y2)
in
return mk_(unitVector(v1),
unitVector(v2),
dotProduct(unitVector(v1),unitVector(v2)),
atan2(0.000001,0.0000000),
vectorRotate(v2,signedVectorAngle(v1,v2)),
radians2degree(signedVectorAngle(v1,v2)),
angleBetweenVectors(v1,v2)
);
end GLOBAL
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
|
Haftungshinweis
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.
|