The given prelude defines three types, one for three dimensional points, another for velocity vectors in three dimensions, and another one representing moving objects in space.
-
Write a function
move : point -> dpoint -> point
such thatmove p dp
is the pointp
whose coordinates have been updated according todp
. (x
is nowx +. dx
,y
is nowy +. dy
,z
is nowz +. dz
). -
Write a function
next : physical_object -> physical_object
such thatnext o
is the physical objecto
at timet + dt
. The position ofnext o
is the position of o moved according to its velocity vector. Suppose that these objects are spheres whose radius is1.0
. -
Write a function
will_collide_soon : physical_object -> physical_object -> bool
that tells if at the next instant, the two spheres will intersect.
type point = { x : float; y : float; z : float }
type dpoint = { dx : float; dy : float; dz : float }
type physical_object = { position : point; velocity : dpoint }
let move p dp =
"Replace this string with your implementation." ;;
let next obj =
"Replace this string with your implementation." ;;
let will_collide_soon p1 p2 =
"Replace this string with your implementation." ;;