Suoritettu

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)

if ([login to view URL](m))

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)

return [login to view URL];

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.

Taidot: C# -ohjelmointi

Tietoa asiakkaasta:
( 418 arvostelua ) Toccoa, United States

Projektin tunnus: #33774541

Myönnetty käyttäjälle:

vw1514518vw

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

$15 USD 1 päivässä
(2 Arvostelua)
1.6

12 freelanceria on tarjonnut keskimäärin $31 tähän työhön

vladang

Hello... I am interested

$30 USD 1 päivässä
(166 arvostelua)
6.8
Muhammadsamran

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 Lisää

$20 USD 7 päivässä
(3 arvostelua)
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 Lisää

$30 USD 1 päivässä
(4 arvostelua)
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 Lisää

$133.33 USD 3 päivässä
(2 arvostelua)
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 Lisää

$20 USD 1 päivässä
(1 arvostelu)
3.0
MaksimKholin

I am genuine c# expert. Pls select me!

$20 USD 1 päivässä
(3 arvostelua)
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 Lisää

$30 USD 1 päivässä
(1 arvostelu)
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 1 päivässä
(0 arvostelua)
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 Lisää

$20 USD 1 päivässä
(0 arvostelua)
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, Lisää

$20 USD 1 päivässä
(0 arvostelua)
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 1 päivässä
(1 arvostelu)
0.1