# Need a C# function to calculate the Y value given the X value of a line

I have a CNC program that I need to see how close the machine points are to multiple lines drawn over the same pattern. What I need is a function that I can pass the points (with the decimal places) for the start and end of the line and the x value I'm looking for the y value to and get the y value for that point on the line (if they are on the line). The function doesn't need to validate that they are on the line as I'll only be passing the ones on the line.

This is what I found online but it's not working the way I need it to.

public static double GetY(double x, double aX, double aY, double m)

{

// Vertical line (y-values are always the same)

return aY;

double c = (aY - aX) * m;

return m * x + c;

}

public static double CalculateSlope(double aX, double aY, double bX, double bY)

{

if (bY == aY)

if (bX == aX)

return 0.0;

return (bY - aY) / (bX - aX);

}

aX = 594.7664

aY = 63.5246

bX = 140.0116

bY = 63.5118

x = 140.0116

y should be 63.5118 but it's actually returning 0.001747275146958124.

x = 200 also returns 0.0034357708373827563 for y.

aX = 140.4297

aY = 62.4948

bX = 140.8548

bY = 61.4806

x = 140.4297

y should be 62.4948 but is returning -149.0995675

I've attached two sample files that I need it to work for.

The Rough [login to view URL] file gives the points for the lines.

Each line is calculated using the point on the current line and the point on the next line.

The points that I need to calculate (assuming they fall between the x on the first line and x on the next line) are in Machine points.csv.

There are the x points that could fall on the line from Rough [login to view URL] and I need to calculate for each point what the value of Y is.

Kemahiran: Pengaturcaraan C#

Tentang Klien:
( 418 ulasan ) Toccoa, United States

ID Projek: #33774541

vw1514518vw

Hi, Function already created, Done, Tested and Ready, Message me to get the formula/function, anyway you will pay after test

\$15 USD dalam sehari
(2 Ulasan)
1.6

## 12 pekerja bebas membida secara purata \$31 untuk pekerjaan ini

Hello... I am interested

\$30 USD dalam sehari
(166 Ulasan)
6.8

Hello Sir/ Ma’am A skilled full stack developer, I have rich experience in JAVA,C, C++, C#, Python, .NET , MYSQL, SQL, IONIC , MATLAB,PHP and ARDUINO. I am very confident with my skills and I'd like to help your bu Lagi

\$20 USD dalam 7 hari
(3 Ulasan)
3.3
Maath

Hello , I am expert at C# and can check and fix this code for you or build the software that gives you the desired results to calculate the value of Y correctly . Please check my profile for related project and what my Lagi

\$30 USD dalam sehari
(4 Ulasan)
3.3
Ghazik

Am ready to create function that I can pass the points (with the decimal places) for the start and end of the line and the x value. please send me a message to discuss further details about this project in chat. than Lagi

\$133.33 USD dalam 3 hari
(2 Ulasan)
3.2
markovicdusan552

Hello How are you. Your project encourages me to help you with perfect result. I developed React js for long time, so your plan is just familiar with me. The main point is your decision to award me for your project. Yo Lagi

\$20 USD dalam sehari
(1 Ulasan)
3.0
MaksimKholin

I am genuine c# expert. Pls select me!

\$20 USD dalam sehari
(3 Ulasan)
2.8
castofilipe86

Hi, I am an export in C++, C#, Java and I have full experience over 10 years. I have good experience developing CNC programs using C++. I will do my best to finish your project in the shortest time with high qualit Lagi

\$30 USD dalam sehari
(1 Ulasan)
1.2
yevheniitsvietk3

HI. I am C# programmer and I just saw your posting. I have enough experience about C# programming. I am interested in your code and now I am analyzing your code. If I find the problem, I will contact you. Thank you.

\$13 USD dalam sehari
(0 Ulasan)
0.0
MrIthen

Hi, i am 20 years of experience in programming including 2D, 3D programing concepts as well as Image Processing, Graphical Programing (OpenGL, WebGL, SVG etc.) and GIS programing concepts. So i have all required Math a Lagi

\$20 USD dalam sehari
(0 Ulasan)
0.0
mykhailodew

Professional software developer️ Hello, I have confirmed your project requirements I hope you are safe and doing well. I would like to discuss further with you. We hope to see you soon to discuss further. Coming to me, Lagi

\$20 USD dalam sehari
(0 Ulasan)
0.0
BestDev2022

Hello, Client! I read your project description and code carefully. I'm a C/C++/python and math expert. I can do this task in a short time. I wish that to discuss with you in detail for this project. Best regards.

\$20 USD dalam sehari
(1 Ulasan)
0.1