Scolring - Forum

Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology

Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered

You are not logged in.

#1 27-Apr-2014 23:09:17

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

interpolating between 2 xy points

hello everyone

I want a widget bitmap to move around the player window. You guys helped me out with the code to interpolate between two positions:

//position interpoloation function
fun vecLerp (v1, v2, coef)=
  let multiplyVectorF v2[coef coef coef] -> v1t in
  let multiplyVectorF v1[(1.0 -. coef) (1.0 -. coef) (1.0 -. coef)] -> v2t in
  addVectorF v1t v2t;;

so what would a function like this look like for 2 xy points where each is an [I I] tuple (an x and y coordinate, where the source position is position1, the target position is position2, and the coefficient is a float (which I have already taken care of and will be passing to this function).  I would want the function to return the interpolated xy position, so it would return a tuple of [I I], like veclerp returns a tuple of [F F F]

fun interpolate_xy_position (position1, position2, coef)=
??
;;

thanks!!!!
-h

Last edited by hebdemnobad (27-Apr-2014 23:09:59)

Offline

#2 28-Apr-2014 08:11:52

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: interpolating between 2 xy points

Hi !

//position interpoloation function
fun vec2ILerp (v1, v2, coef)=
  let v1 -> [x1 y1] in
  let v2 -> [x2 y2] in
  let [(itof x1) *. coef (itof y1) *. coef] -> [x1t y1t] in
  let [(itof x2) *. (1.0 -. coef) (itof y2) *. (1.0 -. coef)] -> [x2t y2t] in
  [ftoi (x1t +. x2t) ftoi (y1t +. y2t)];;

Offline

#3 28-Apr-2014 12:43:55

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: interpolating between 2 xy points

Thx I'll try that.

Offline

Board footer

Powered by FluxBB