# Thread: Urgent help in finding out a point on a line

1. ## Urgent help in finding out a point on a line

Hi,

This is my scenario.

I have a line and I know that it is originating at x1,y1.
I also know the angle of the line with respect to the base.
Given a distance from the x1,y1 I need to know the other points x2,y2

How do I do this.

can anyone help me with providing a formula say

x2= so and so
and
y2 = so and so

I've to use this in a computer language and so would be glad if I could get a formula such as the above.

Please guys help needed.

Thanks in advance.

2. Originally Posted by hari-kj
Hi,

This is my scenario.
I have a line and I know that it is originating at x1,y1.
I also know the angle of the line with respect to the base.
Given a distance from the x1,y1 I need to know the other points x2,y2

How do I do this.
can anyone help me with providing a formula say
x2= so and so
and
y2 = so and so
I've to use this in a computer language and so would be glad if I could get a formula such as the above.
Please guys help needed. Thanks in advance.

Hello,

you have the variables x1, y1, x2, y2, distance, angle which are the type real.

The varaibles x1, y1, distance and angle have got a value by an input procedure. The angle is given in degrees.

Then
x2:=x1+distance*cos(pi/180*angle);
y2:=y1+distance*sin(pi/180*angle);

OR

x2:=x1-distance*cos(pi/180*angle);
y2:=y1-distance*sin(pi/180*angle);

You have to write an output procedure and if you want to draw these lines and points must change the data type from real to integer.

Greetings

EB

3. Hi:

Your wording has me a bit confused. For instance, you write "it is originating at x1,y1" (it referring to the line). But lines do not originate from any specific point. Rays do, but not lines. Secondly, you refer to an angle "with respect to the base". What base? Do you mean the angle relative to horizontal?

So, I will assume that your intent is to convey the following: "Given a line in the coodinate plane with angle, ß, relative to horizontal, and containing point P(x1,y1), find the coordinates of point Q on the line, such that PQ=distance d.". Your question refers to a single point. But the line contains two points at distance, d. Which would you like to know about?

I await your reply.

Rich B.

4. Hi earboth,

Thanks for the answer. That was too simple and worked out for me

can you please explain the formula here?!!

Rich B. Thanks for the input and your understanding of the question is correct. I'm not that much of a Math person now, have graduated out a long time back and use math formulas rather than explaining them

Also one more question.

The main reason I wanted to do this is to draw two lines based on an angle which is a user's input.

Now that I've done the angle creation part, one thing is remaining, the curve representing the angle.

How do I draw the curve now that I know the start and the endpoint of the curve and the radius of the curve.

Any formula for that too.

Sorry if I'm asking for too much.

5. Originally Posted by hari-kj
Hi earboth,
Thanks for the answer. That was too simple and worked out for me
can you please explain the formula here?!!

Rich B. Thanks for the input and your understanding of the question is correct. I'm not that much of a Math person now, have graduated out a long time back and use math formulas rather than explaining them

Also one more question.
The main reason I wanted to do this is to draw two lines based on an angle which is a user's input.
Now that I've done the angle creation part, one thing is remaining, the curve representing the angle.
How do I draw the curve now that I know the start and the endpoint of the curve and the radius of the curve.
Any formula for that too.
Sorry if I'm asking for too much.
Hello,

as I understand you right, you've got a problem to find the commands so you can draw a part of a circle line.
The commands I gave you with my previous post are Delphi- (or Pascal) code. Because I don't know which programming language you use I can give you only more general hints what to do: Most languages have functions like ARC. Sometimes this function is implemented into the function CIRCLE or ELLIPSE. Please check the manual of your programming language.

I've attached a diagram, which was drawn by the (Delphi-)command:
CANVAS.AR(x1, y1, x2, y2, x3, y3, x4, y4 : integer);

Greetings

EB