none
Painting a projectile's curve GDI RRS feed

  • Question

  • Hi, I have the height and range of projectile making a rectangle in x, y coordinate space. How should I figure out and draw the projectile curve in that rectangular area at a certain angle of projection using GDI?
    Sunday, October 31, 2010 2:44 PM

Answers

  • David_21 wrote:

    Hi, I have the height and range of projectile making a rectangle in x,  y coordinate space. How should I figure out and draw the
    projectile curve in that rectangular area at a certain angle of  projection using GDI?

    You can draw line segments with MoveTo and LineTo (or with Polyline, if  you want to be fancy). The trick now is to figure out which points the  curve should pass through. Engage your Physics 101 skills for that.


    Igor Tandetnik

    • Marked as answer by Parcxs Monday, November 1, 2010 4:52 PM
    Sunday, October 31, 2010 2:56 PM
  • Compute Y (in pixels) for every X (in pixels).  Put the whole (X,Y) array into Polyline.  It will (appear to) curve.

     

    • Marked as answer by Parcxs Monday, November 1, 2010 4:52 PM
    Sunday, October 31, 2010 11:52 PM
  • David_21 wrote:

    Thanks, but how would it be possible to draw or make it into a curved  path? maybe if somehow I bend the line to make a curve from
    the center point of range.

    A curve can be approximated arbitrarily closely with a sequence of short  straight lines (the shorter the lines, the more accurate the  approximation). If you calculate points on the curve every 10 pixels or  so, and join them with straight lines, your eye won't notice the  difference.

    The display is a raster device consisting of a finite number of pixels.  It can render arbirary curves only approximately. Take a sheet of graph  paper; imagine that you are only allowed to completely fill some squares  with pencil, while leaving others untouched. Try drawing a curve (any  curve) under these conditions.


    Igor Tandetnik

    • Marked as answer by Parcxs Monday, November 1, 2010 4:52 PM
    Monday, November 1, 2010 1:22 AM

All replies

  • David_21 wrote:

    Hi, I have the height and range of projectile making a rectangle in x,  y coordinate space. How should I figure out and draw the
    projectile curve in that rectangular area at a certain angle of  projection using GDI?

    You can draw line segments with MoveTo and LineTo (or with Polyline, if  you want to be fancy). The trick now is to figure out which points the  curve should pass through. Engage your Physics 101 skills for that.


    Igor Tandetnik

    • Marked as answer by Parcxs Monday, November 1, 2010 4:52 PM
    Sunday, October 31, 2010 2:56 PM
  • Thanks, but how would it be possible to draw or make it into a curved path? maybe if somehow I bend the line to make a curve from the center point of range.
    Sunday, October 31, 2010 10:53 PM
  • Compute Y (in pixels) for every X (in pixels).  Put the whole (X,Y) array into Polyline.  It will (appear to) curve.

     

    • Marked as answer by Parcxs Monday, November 1, 2010 4:52 PM
    Sunday, October 31, 2010 11:52 PM
  • David_21 wrote:

    Thanks, but how would it be possible to draw or make it into a curved  path? maybe if somehow I bend the line to make a curve from
    the center point of range.

    A curve can be approximated arbitrarily closely with a sequence of short  straight lines (the shorter the lines, the more accurate the  approximation). If you calculate points on the curve every 10 pixels or  so, and join them with straight lines, your eye won't notice the  difference.

    The display is a raster device consisting of a finite number of pixels.  It can render arbirary curves only approximately. Take a sheet of graph  paper; imagine that you are only allowed to completely fill some squares  with pencil, while leaving others untouched. Try drawing a curve (any  curve) under these conditions.


    Igor Tandetnik

    • Marked as answer by Parcxs Monday, November 1, 2010 4:52 PM
    Monday, November 1, 2010 1:22 AM