Square root?

Started by stuh505, Thu 13/05/2004 23:58:16

Previous topic - Next topic

stuh505

How do I get the square root?Ã,  Do I need to write a cumbersome approximation (using a cumbersome algorithm to compute powers as well)?

(I need this in order to compute the distance between two points for the function I am writing to slide graphic overlays since none seems to exist...and I need to slide graphic overlays instead of objects because I can't create objects during runtime!Ã,  sheesh, it's just one roundabout after another)

EDIT: nooo!Ã,  I can't even use a decimel data type to store the number...I'll need to write an approximation for that too...oh dear god.

EDIT 2:  ok...forget this...I'm abandoning diagonal movement and easily adjustable movement speeds.  I wrote the function more simplified, it slides horizontally then vertically to the new position, and to control speed you set the step (pixel jump) and pause (probably zero) between steps.  here it is if anyone wants it, its nothing special but might save u time.



function LW_SlideOverlay(int overlayID, int x, int y, int newx, int newy, int step, int delay){
// can only slide vertically or horizontally
// step MUST BE > 0
  if (x<newx){ //if moving right
    while (x<newx){
      MoveOverlay(overlayID,x+step,y);
      x = x+step;
      Wait(delay);
    }
  } else if (x>newx){ //if moving left
    while (x>newx){
      MoveOverlay(overlayID,x-step,y);
      x=x-step;
      Wait(delay);
    }
  }

  if (y<newy){ //if moving down
    while (y<newy){
      MoveOverlay(overlayID,x,y+step);
      y=y+step;
      Wait(delay);
    }
  } else if (y>newy){ //if moving up
    while (y>newy){
      MoveOverlay(overlayID,x,y-step);
      y=y-step;
      Wait(delay);
    }
  }
}

Gilbert

#1
If you're still looking for square roots, read this.

stuh505


SMF spam blocked by CleanTalk