Results 1 to 3 of 3

Thread: help needed

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    5

    help needed

    hi,

    I have a line drawn on a grid all i know is start and end co-ords of the line from the start co-ord i need to calculate a point on the line that is just slightly further down the line than the first point. is this possibe?

  2. #2
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Re: help needed

    If I understand correctly, you have the coordinates of 2 points that define a line (let's call them x1,y1 and x2,y2) and you want to know the coordinates of a point x,y that is a certain distance d along the line from x1,y1 in the direction of x2,y2. If that's what you are looking for, following methodology applies.

    1. The line is at an angle to horizontal. The tangent of the angle (theta) is: tan(theta) = (y2 - y1)/(x2 - x1). Calculate theta

    2. The unknown point x,y is a distance d along the line from point x1, y1 in the direction of x2,y2.
    x = x1 + d*cos(theta)
    y = y1 + d*sin(theta)

  3. #3
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: help needed

    Or you can calculate the length of the line L to be sqrt(dx^2 + dy^2), where dx is x2 - x1 and dy is y2-y1. If you are looking for distance l along the line D, then x' = x1+(dx*l/L) and y' = y1+(dy*l/L).

    It amounts to the same thing.

    zaza
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

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