code_junkie

Algorithm 2D Referential traduction

Nov 12th, 2011
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. if x < 0
  2. new x = (x - xmin) * (250 / (xmax - xmin)) ?
  3.  
  4. for (int xcanvas = 0; xcanvas <= 250; i++) {
  5. double x = ((xmax - xmin) * xcanvas / 250.0) + xmin;
  6. double y = f(x);
  7.  
  8. int ycanvas = 250 * (y - ymin) / (ymax - ymin) + .5;
  9.  
  10. // Plot (xcanvas, ycanvas)
  11. }
  12.  
  13. (canvas_x, canvas_y) -> (maths_x, maths_y)
  14. (maths_x, maths_y) -> (canvas_x, canvas_y)
  15.  
  16. maths_x -> maths_y
  17.  
  18. maths_x = maths_x_from_canvas_x(canvas_x, min_maths_x, max_maths_x)
  19. maths_y = maths_y_from_maths_x(maths_x) # this is the function to be plotted.
  20. canvas_y = canvas_y_from_maths_y(maths_y, min_maths_y, max_maths_y)
  21.  
  22. if (canvas_y not out of bounds) plot(canvas_x, canvas_y)
Add Comment
Please, Sign In to add comment