1 definition module Geometry
3 /** This module defines the part of the SoccerFun API that is concerned with the footballer dimensions.
8 class scale a :: !Real !a -> a
12 m :: !Real -> Metre // (m metre) is a distance in metres
23 instance toString Metre
28 = { px :: !Metre // x-coordinate in plane
29 , py :: !Metre // y-coordinate in plane
32 = { pxy :: !Position // position on plane
33 , pz :: !Metre // height above plane
36 instance zero Position
37 instance zero Position3D
39 instance == Position3D
40 instance toString Position
41 instance toString Position3D
43 class toPosition a :: !a -> Position
44 class fromPosition a :: !Position -> a
45 class toPosition3D a :: !a -> Position3D
46 class fromPosition3D a :: !Position3D -> a
47 instance toPosition (!Metre,!Metre)
48 instance toPosition Position
49 instance toPosition Position3D
50 instance fromPosition (!Metre,!Metre)
51 instance fromPosition Position
52 instance fromPosition Position3D
53 instance toPosition3D (!Metre,!Metre,!Metre)
54 instance toPosition3D Position
55 instance toPosition3D Position3D
56 instance fromPosition3D (!Metre,!Metre,!Metre)
57 instance fromPosition3D Position
58 instance fromPosition3D Position3D
60 dist :: !a !b -> Metre | toPosition3D a & toPosition3D b
65 pi :== 3.1415926535897932384 // (rad pi) is equivalant with (degree 180)
67 rad :: !Real -> Angle // (rad x) is an angle of x radians (counter-clockwise)
68 degree :: !Int -> Angle // (degree x) is an angle of x degrees (counter-clockwise)
80 instance toString Angle
83 instance cosinus Angle
84 instance tangens Angle
85 instance arcsinus Angle
86 instance arccosinus Angle
87 instance arctangens Angle
90 returns the left- and right- orthogonal angles to a
92 orthogonal :: !Angle -> (!Angle,!Angle)
94 /** bearing nose base target:
95 returns the smallest rotation angle needed for a player at @base having current direction @nose
97 The result is a value between ~pi and pi.
99 bearing :: !Angle !base !target -> Angle | toPosition base & toPosition target
103 = { dx :: !Metre // difference in px-coordinate
104 , dy :: !Metre // difference in py-coordinate
111 class toRVector a :: !a -> RVector
112 instance toRVector Angle
113 instance toRVector Position
115 /** size_vector {dx, dy} = sqrt ( dx^2 + dy^2)
116 size_vector3D {dxy,dz} = sqrt (dxy.dx^2 + dxy.dy^2 + dz^2)
118 size_vector :: !RVector -> Metre
119 size_vector3D :: !RVector3D -> Metre
125 instance zero RVector
126 instance zero RVector3D
128 instance one RVector3D
131 instance scale RVector
132 instance scale RVector3D
136 moves point p over vector v.
138 moves point p over vector v.
140 move_point :: !RVector !Position -> Position
141 move_point3D :: !RVector3D !Position3D -> Position3D
143 /** repell minimum_distance base pos:
144 if @pos is too close to @base, compute a new position that is at least @minimum_distance metres away from @base.
145 attract maximum_distance base pos:
146 if @pos is too far away from @base, compute a new position that is at most @maximum_distance metres away from @base.
148 repell :: !Metre !Position !Position -> Position
149 attract :: !Metre !Position !Position -> Position
151 /** point_to_rectangle (a,b) c
152 returns c if (point_in_rectangle (a,b) c) and the projected point c` of c that is exactly on the closest edge of
155 point_to_rectangle :: !(!Position,!Position) !Position -> Position
157 /** point_in_rectangle (a,b) c
158 returns True iff point c is inside the rectangle determined by
159 the diagonal corner points a and b.
161 point_in_rectangle :: !(!Position,!Position) !Position -> Bool
166 ms :: !Real -> Velocity // (ms metre-per-second) is a velocity
168 instance zero Velocity
171 instance abs Velocity
172 instance sign Velocity
176 instance toReal Velocity
177 instance toString Velocity
178 instance scale Velocity
181 :: Speed // speed of an object
182 = { direction :: !Angle // direction of object
183 , velocity :: !Velocity // velocity of object
185 :: Speed3D // speed of an object in space
186 = { vxy :: !Speed // surface speed of object
187 , vz :: !Velocity // velocity in z-axis (positive: goes up; negative: goes down; zero: horizontally)
191 instance zero Speed3D
194 instance toString Speed
195 instance toString Speed3D
197 class toSpeed a :: !a -> Speed
198 class fromSpeed a :: !Speed -> a
199 class toSpeed3D a :: !a -> Speed3D
200 class fromSpeed3D a :: !Speed3D -> a
202 instance toSpeed Speed3D
203 instance fromSpeed Speed3D
204 instance toSpeed3D Speed
205 instance fromSpeed3D Speed