Draw straight line joining two points

Discussion in 'PHP' started by JEET, Mar 28, 2017.

  1. #1
    Here's my problem.
    I need to draw a "straight" line on a chart from point A to point C, which passes through point B.
    I have coords for A and B, but only x coord is available for point C.
    How do I calculate "y" of point C?


    $a = array( 100, 200 );
    $b = array( 200, 176 );
    $c = array( 300, '' );

    imageline( $im, $a[0], $a[1], $c[0], $c[1], $color );

    This line from A to C should pass through B (200, 176), and should be a straight line.
    Any ideas?
    Thanks
     
    Solved! View solution.
    JEET, Mar 28, 2017 IP
  2. #2
    Since the x axis of the line appears to have b halfway between a and c I'd expect the y axis to be the same.

    200 - 176 = 24
    176 - 24 = 154

    so 154
     
    sarahk, Mar 28, 2017 IP
  3. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #3
    Thanks. worked.
     
    JEET, Mar 28, 2017 IP