Help With Making an Arc/Parabola

Discussion in 'iOS Programming' started by mandude, Nov 19, 2009.

  1. mandude macrumors member

    Nov 19, 2009
    hello, whoever can help me with this will know that they are jusus christ reincarnate. So im trying to make an arc/parabola that has 2 intersecting points obviously, and the highest point on this arc will be always always 50 pixes high. Now the first point the parabola crosses will always be the same point, (252,220) the second point its to be where ever i tap the screen. so to wrap things up i need a parabola, one point of intersection is always (252,220) the second is where ever the user taps the screen, with a height of always 50 pixels. thats not even half the problem. :) So far, heres my code... not working out too good :p
    - (void)drawRect: (CGRect)rect {
    	CGContextRef context = UIGraphicsGetCurrentContext(); 
        CGContextSetLineWidth(context, 5.0); 
        CGContextSetStrokeColorWithColor(context, currentColor.CGColor); 
    	CGContextSetFillColorWithColor(context, currentColor.CGColor); 
        switch (shapeType) { 
       case kParabolaShape:
    			CGContextMoveToPoint(context, 252, 220);
    			CGContextAddArcToPoint(context 252, 220, firstTouch.x, firstTouch.y, 50.0);
    Now once i get that to work right, i also need an image (image.png) to be animated and follow the arc/parabola that is created everytime the user taps. So when the user taps the screen, an arc 50 pixels high appears between where they tapped and (252,220) and then they see an image (image.png) move across the drawn parabola and then dissappear whoever can get this i love you

    this is the basic idea of what it should be like:
  2. newb16 macrumors regular

    Feb 27, 2008
    Intersection with what? With the line (y=220) ? Height above what - about the same line (y=220) ?
    Then, if it's an arc, it has limitations - if touch point is less than 100 pixels from the first 'intersection' point, you can't make an arc with such radius to have any point with spicified 'height' (above y=220 line).
    The parabola is another story - I don't know if there are api methods other that building it from splines or line segments.

    First parameter of ArcToPoint with the current point defines a line - so they should not be equal.
    Assuming d is distance from origin(252, 220) to touch point, and R is desired radius of arc, (R-50)**2 + (d/2)**2 == R**2
    The height of point (H) in the first two arguments of ArcToPoint above that bse line is ( if we consider triangles composed of chord ( base line within the arc), radius to the origin point and vertical radius ) : (r-50)/(d/2) == (d/2)/H
    Its x coordinate, obviously, it in the middle between the origin and the touch.

Share This Page