CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2010
    Posts
    172

    Exclamation Expressing y-y1=m(x-x1) programmatically

    How would you express the common line equation programmatically. for example say if you have a straight line across the screen is there a way to work out the gradient. ect..

  2. #2
    Join Date
    Jun 2012
    Posts
    8

    Wink Re: Expressing y-y1=m(x-x1) programmatically

    hi there !
    i'm not a mathematician, but i can help you with programming only if you wrote the exact formula in the most explicit way.
    my code will be in C++ and you can run it either under an MS DOS Consol or embed it in to a Visual C++ application.

    out.

  3. #3
    Join Date
    Oct 2010
    Posts
    32

    Re: Expressing y-y1=m(x-x1) programmatically

    This is very (!) elementary maths.

    In your equation m is the gradient equalling tan (alpha) with alpha being the angle between positive x-axis and your line.

    You can easily transform this equation to the more commonly known form which is easy to code

    y = m * x + n

    with n = y1 - m * x1 as a constant giving the point where the line intersects the y-axis.

    Norbert

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured