# Math Help - EndPoint based on Length and Angle

1. ## EndPoint based on Length and Angle

Hello everyone,
I am needing to find a point perpendicular to a line by an offset.
I'm almost there, but I can't seem to figure out the last piece of the puzzle...

Line A is a physical line. Line B is a "construction" line and will start at X1,Y1 of Line A. Line B's angle is the angle of Line A + 90. Line B's length is 75. If unit type is important, these are measurments in Feet.

Line A:
X1: 2279540.5757 X2: 2279495.2158
Y1: 841723.9968 Y2: 841750.9777
Angle: 149.2551

Line B:
X1: 2279540.5757 X2: ?
Y1: 841723.9968 Y2: ?
Angle: 239.25505248572242
Length: 75

I've drawn Line B out and kn0w the answer for X2,Y2 but I need to figure out the formula to put into an application that I am working on.

X2: 2279502.2344
Y2: 841659.5380

I tried this formula that I found on another forum, but the values are off...
X2 = (75 * Sin(239.2550)) + 2279540.5757
Y2 = (75 * Cos(239.2550)) + 841723.9968

Which gives a result of:
X2: 2279606.6085
Y2: 841759.5589

So the results are off by about 100' in both the X and Y.

Any help with the will be greatly appreciated! Thank you all for your time and help.

2. Originally Posted by nclayton
...

I tried this formula that I found on another forum, but the values are off...
X2 = (75 * Sin(239.2550)) + 2279540.5757
Y2 = (75 * Cos(239.2550)) + 841723.9968

... and help.
You have the concept correct -- just swap the trig functions.

When working with cartesian coordinates,
the sin() will give the distance to be added/subtracted to the Y coordinate. Since 239+ degrees is in the third quadrant, the sin value is negative.
the cos() will give the distance to be added/subtracted to the X coordinate.
You can look at the sin/cos definitions to clarify this.

Try this:
X2 = (75 * cos(239.2550)) + 2279540.5757
Y2 = (75 * sin(239.2550)) + 841723.9968

Your calculator should provide the correct sign for the sin/cos values.
However in this case BOTH the sin/cos values will be negative.

3. Thank you for the reply, it has gotten me closer to the answer I need

I swapped the Cos and Sin and now come up with:

X2 = (75 * cos(239.2550)) + 2279540.5757
Y2 = (75 * sin(239.2550)) + 841723.9968

Replaced with values:

2279576.1377 = (75 * 0.8804) + 2279540.5757
841790.0297 = (75 * 0.4742) + 841723.9968

I am actually using this formula in an application I'm writing in C#. I'm hoping it is giving the correct Cos and Sin values...though they both came back as positive values.

4. Your computer is using radians to measure the angle. But your measurements are in degrees. You'll either need to tell the computer to use degrees or convert the measurements to radians before plugging them in to the sine and cosine functions. Note that there are $2{\pi}$ radians in 360 degrees.

5. Originally Posted by pflo
Your computer is using radians to measure the angle. But your measurements are in degrees. You'll either need to tell the computer to use degrees or convert the measurements to radians before plugging them in to the sine and cosine functions. Note that there are $2{\pi}$ radians in 360 degrees.

That was exactly my problem...I was converting the radians to degrees because most of the drafting software I work with uses degrees. I think I've finally got a solid solution to use in my application, thank you guys for all the help!

Here is what I ended up using...

If the degrees(angle) is > 0 and < 90:
x2 = x1 + (offset * Abs(Cos(radians(angle))))
y2 = y1 + (offset * Abs(Sin(radians(angle))))

If the degrees(angle) is > 90 and < 180:
x2 = x1 - (offset * Abs(Cos(radians(angle))))
y2 = y1 + (offset * Abs(Sin(radians(angle))))

If the degrees(angle) is > 180 and < 270:
x2 = x1 - (offset * Abs(Cos(radians(angle))))
y2 = y1 - (offset * Abs(Sin(radians(angle))))

If the degrees(angle) is > 270 and < 360:
x2 = x1 + (offset * Abs(Cos(radians(angle))))
y2 = y1 - (offset * Abs(Sin(radians(angle))))

If the degrees(angle) = 0:
x2 = x1 + offset
y2 = y1

If the degrees(angle) = 90:
x2 = x1
y2 = y1 + offset

if the degrees(angle) = 180:
x2 = x1 - offset
y2 = y1

If the degrees(angle) = 270:
x2 = x1
y2 = y1 - offset

Again, thank you all for the help