How to link curves [closed]












1















First of all, let me make it clear that I don't know much about programming. So after I got that out of the way, thanks for reading my question.



So what I currently want to cram into my little C# programm is the following:




  • Draw a line from pA to pX

  • Draw a curve from pX to pY

  • Draw a curve from pY to pZ

  • Draw a line from pZ to pD


My problem with this is the following:



How on earth do I "switch" from a line to a curve, to another curve and then back to a line in C#?



I'd be really happy if anyone could help me with this.



Greetings from Belgium,



-g2609










share|improve this question















closed as too broad by Dour High Arch, Gert Arnold, CozyAzure, greg-449, EdChum Nov 26 '18 at 9:21


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • 2





    which framework? winforms, WPF, the web? show the code you've written so far, and describe the problems with it.

    – dlatikay
    Nov 25 '18 at 16:26













  • In general, I only need the x and y coordinates between points. It's for controling a Robot.

    – Giebels2609
    Nov 25 '18 at 16:28











  • a line is just an edge case of a curve. it does not matter if you connect line-line, curve-line or curve-curve. anyway, we need to know a bit more about input and expected output to help here. here is a recent answer showing how a graphics library can be used to get a list of points from a path (which in turn may consist of a sequence of lines/curves, which are just drawn one after the other

    – dlatikay
    Nov 25 '18 at 16:30













  • Ok, didn't know that. So basically I will tell the robot the start position, the end position and "weight points" and how many steps it should take from start to end. As output, I need xy coordinates for each step

    – Giebels2609
    Nov 25 '18 at 16:32






  • 1





    don't forget the Z coordinate, its not discworld :)

    – dlatikay
    Nov 25 '18 at 16:38
















1















First of all, let me make it clear that I don't know much about programming. So after I got that out of the way, thanks for reading my question.



So what I currently want to cram into my little C# programm is the following:




  • Draw a line from pA to pX

  • Draw a curve from pX to pY

  • Draw a curve from pY to pZ

  • Draw a line from pZ to pD


My problem with this is the following:



How on earth do I "switch" from a line to a curve, to another curve and then back to a line in C#?



I'd be really happy if anyone could help me with this.



Greetings from Belgium,



-g2609










share|improve this question















closed as too broad by Dour High Arch, Gert Arnold, CozyAzure, greg-449, EdChum Nov 26 '18 at 9:21


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • 2





    which framework? winforms, WPF, the web? show the code you've written so far, and describe the problems with it.

    – dlatikay
    Nov 25 '18 at 16:26













  • In general, I only need the x and y coordinates between points. It's for controling a Robot.

    – Giebels2609
    Nov 25 '18 at 16:28











  • a line is just an edge case of a curve. it does not matter if you connect line-line, curve-line or curve-curve. anyway, we need to know a bit more about input and expected output to help here. here is a recent answer showing how a graphics library can be used to get a list of points from a path (which in turn may consist of a sequence of lines/curves, which are just drawn one after the other

    – dlatikay
    Nov 25 '18 at 16:30













  • Ok, didn't know that. So basically I will tell the robot the start position, the end position and "weight points" and how many steps it should take from start to end. As output, I need xy coordinates for each step

    – Giebels2609
    Nov 25 '18 at 16:32






  • 1





    don't forget the Z coordinate, its not discworld :)

    – dlatikay
    Nov 25 '18 at 16:38














1












1








1


1






First of all, let me make it clear that I don't know much about programming. So after I got that out of the way, thanks for reading my question.



So what I currently want to cram into my little C# programm is the following:




  • Draw a line from pA to pX

  • Draw a curve from pX to pY

  • Draw a curve from pY to pZ

  • Draw a line from pZ to pD


My problem with this is the following:



How on earth do I "switch" from a line to a curve, to another curve and then back to a line in C#?



I'd be really happy if anyone could help me with this.



Greetings from Belgium,



-g2609










share|improve this question
















First of all, let me make it clear that I don't know much about programming. So after I got that out of the way, thanks for reading my question.



So what I currently want to cram into my little C# programm is the following:




  • Draw a line from pA to pX

  • Draw a curve from pX to pY

  • Draw a curve from pY to pZ

  • Draw a line from pZ to pD


My problem with this is the following:



How on earth do I "switch" from a line to a curve, to another curve and then back to a line in C#?



I'd be really happy if anyone could help me with this.



Greetings from Belgium,



-g2609







c# math line bezier curve






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 16:35







Giebels2609

















asked Nov 25 '18 at 16:25









Giebels2609Giebels2609

86




86




closed as too broad by Dour High Arch, Gert Arnold, CozyAzure, greg-449, EdChum Nov 26 '18 at 9:21


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as too broad by Dour High Arch, Gert Arnold, CozyAzure, greg-449, EdChum Nov 26 '18 at 9:21


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 2





    which framework? winforms, WPF, the web? show the code you've written so far, and describe the problems with it.

    – dlatikay
    Nov 25 '18 at 16:26













  • In general, I only need the x and y coordinates between points. It's for controling a Robot.

    – Giebels2609
    Nov 25 '18 at 16:28











  • a line is just an edge case of a curve. it does not matter if you connect line-line, curve-line or curve-curve. anyway, we need to know a bit more about input and expected output to help here. here is a recent answer showing how a graphics library can be used to get a list of points from a path (which in turn may consist of a sequence of lines/curves, which are just drawn one after the other

    – dlatikay
    Nov 25 '18 at 16:30













  • Ok, didn't know that. So basically I will tell the robot the start position, the end position and "weight points" and how many steps it should take from start to end. As output, I need xy coordinates for each step

    – Giebels2609
    Nov 25 '18 at 16:32






  • 1





    don't forget the Z coordinate, its not discworld :)

    – dlatikay
    Nov 25 '18 at 16:38














  • 2





    which framework? winforms, WPF, the web? show the code you've written so far, and describe the problems with it.

    – dlatikay
    Nov 25 '18 at 16:26













  • In general, I only need the x and y coordinates between points. It's for controling a Robot.

    – Giebels2609
    Nov 25 '18 at 16:28











  • a line is just an edge case of a curve. it does not matter if you connect line-line, curve-line or curve-curve. anyway, we need to know a bit more about input and expected output to help here. here is a recent answer showing how a graphics library can be used to get a list of points from a path (which in turn may consist of a sequence of lines/curves, which are just drawn one after the other

    – dlatikay
    Nov 25 '18 at 16:30













  • Ok, didn't know that. So basically I will tell the robot the start position, the end position and "weight points" and how many steps it should take from start to end. As output, I need xy coordinates for each step

    – Giebels2609
    Nov 25 '18 at 16:32






  • 1





    don't forget the Z coordinate, its not discworld :)

    – dlatikay
    Nov 25 '18 at 16:38








2




2





which framework? winforms, WPF, the web? show the code you've written so far, and describe the problems with it.

– dlatikay
Nov 25 '18 at 16:26







which framework? winforms, WPF, the web? show the code you've written so far, and describe the problems with it.

– dlatikay
Nov 25 '18 at 16:26















In general, I only need the x and y coordinates between points. It's for controling a Robot.

– Giebels2609
Nov 25 '18 at 16:28





In general, I only need the x and y coordinates between points. It's for controling a Robot.

– Giebels2609
Nov 25 '18 at 16:28













a line is just an edge case of a curve. it does not matter if you connect line-line, curve-line or curve-curve. anyway, we need to know a bit more about input and expected output to help here. here is a recent answer showing how a graphics library can be used to get a list of points from a path (which in turn may consist of a sequence of lines/curves, which are just drawn one after the other

– dlatikay
Nov 25 '18 at 16:30







a line is just an edge case of a curve. it does not matter if you connect line-line, curve-line or curve-curve. anyway, we need to know a bit more about input and expected output to help here. here is a recent answer showing how a graphics library can be used to get a list of points from a path (which in turn may consist of a sequence of lines/curves, which are just drawn one after the other

– dlatikay
Nov 25 '18 at 16:30















Ok, didn't know that. So basically I will tell the robot the start position, the end position and "weight points" and how many steps it should take from start to end. As output, I need xy coordinates for each step

– Giebels2609
Nov 25 '18 at 16:32





Ok, didn't know that. So basically I will tell the robot the start position, the end position and "weight points" and how many steps it should take from start to end. As output, I need xy coordinates for each step

– Giebels2609
Nov 25 '18 at 16:32




1




1





don't forget the Z coordinate, its not discworld :)

– dlatikay
Nov 25 '18 at 16:38





don't forget the Z coordinate, its not discworld :)

– dlatikay
Nov 25 '18 at 16:38












1 Answer
1






active

oldest

votes


















0














Seems you want to provide smooth connection of line segments and curves.



Note that Bezier curves at the end points have direction (tangents) to control points. So just put control points at the continuation of straight segments. Distance from the enpoints to the control ones is responsible for curvature. Try to use values like distXY / 3 to start.



For curve-curve connection you have to define some rule. For example, define tangent direction (and maginute again). If you need smooth curve chain, consider interpolation splines - this approach calculates cubic curves parameters for all curves and provides continuity.



Pseudocode for line A-X, cubic Bezier X-Y, line Y-Z.



 VecAX = X - A
uAX = (VecAX.X / VecAX.Length, VecAX.Y / VecAX.Length)
curveXY.P0 = X
curveXY.P1 = X + uAX * VecAX.Length / 3
curveXY.P2 = Y - uXZ * VecXZ.Length / 3
curveXY.P3 = Y





share|improve this answer


























  • Sounds reasonable. Thanks for the help mate

    – Giebels2609
    Nov 25 '18 at 18:06


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Seems you want to provide smooth connection of line segments and curves.



Note that Bezier curves at the end points have direction (tangents) to control points. So just put control points at the continuation of straight segments. Distance from the enpoints to the control ones is responsible for curvature. Try to use values like distXY / 3 to start.



For curve-curve connection you have to define some rule. For example, define tangent direction (and maginute again). If you need smooth curve chain, consider interpolation splines - this approach calculates cubic curves parameters for all curves and provides continuity.



Pseudocode for line A-X, cubic Bezier X-Y, line Y-Z.



 VecAX = X - A
uAX = (VecAX.X / VecAX.Length, VecAX.Y / VecAX.Length)
curveXY.P0 = X
curveXY.P1 = X + uAX * VecAX.Length / 3
curveXY.P2 = Y - uXZ * VecXZ.Length / 3
curveXY.P3 = Y





share|improve this answer


























  • Sounds reasonable. Thanks for the help mate

    – Giebels2609
    Nov 25 '18 at 18:06
















0














Seems you want to provide smooth connection of line segments and curves.



Note that Bezier curves at the end points have direction (tangents) to control points. So just put control points at the continuation of straight segments. Distance from the enpoints to the control ones is responsible for curvature. Try to use values like distXY / 3 to start.



For curve-curve connection you have to define some rule. For example, define tangent direction (and maginute again). If you need smooth curve chain, consider interpolation splines - this approach calculates cubic curves parameters for all curves and provides continuity.



Pseudocode for line A-X, cubic Bezier X-Y, line Y-Z.



 VecAX = X - A
uAX = (VecAX.X / VecAX.Length, VecAX.Y / VecAX.Length)
curveXY.P0 = X
curveXY.P1 = X + uAX * VecAX.Length / 3
curveXY.P2 = Y - uXZ * VecXZ.Length / 3
curveXY.P3 = Y





share|improve this answer


























  • Sounds reasonable. Thanks for the help mate

    – Giebels2609
    Nov 25 '18 at 18:06














0












0








0







Seems you want to provide smooth connection of line segments and curves.



Note that Bezier curves at the end points have direction (tangents) to control points. So just put control points at the continuation of straight segments. Distance from the enpoints to the control ones is responsible for curvature. Try to use values like distXY / 3 to start.



For curve-curve connection you have to define some rule. For example, define tangent direction (and maginute again). If you need smooth curve chain, consider interpolation splines - this approach calculates cubic curves parameters for all curves and provides continuity.



Pseudocode for line A-X, cubic Bezier X-Y, line Y-Z.



 VecAX = X - A
uAX = (VecAX.X / VecAX.Length, VecAX.Y / VecAX.Length)
curveXY.P0 = X
curveXY.P1 = X + uAX * VecAX.Length / 3
curveXY.P2 = Y - uXZ * VecXZ.Length / 3
curveXY.P3 = Y





share|improve this answer















Seems you want to provide smooth connection of line segments and curves.



Note that Bezier curves at the end points have direction (tangents) to control points. So just put control points at the continuation of straight segments. Distance from the enpoints to the control ones is responsible for curvature. Try to use values like distXY / 3 to start.



For curve-curve connection you have to define some rule. For example, define tangent direction (and maginute again). If you need smooth curve chain, consider interpolation splines - this approach calculates cubic curves parameters for all curves and provides continuity.



Pseudocode for line A-X, cubic Bezier X-Y, line Y-Z.



 VecAX = X - A
uAX = (VecAX.X / VecAX.Length, VecAX.Y / VecAX.Length)
curveXY.P0 = X
curveXY.P1 = X + uAX * VecAX.Length / 3
curveXY.P2 = Y - uXZ * VecXZ.Length / 3
curveXY.P3 = Y






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 25 '18 at 17:33

























answered Nov 25 '18 at 17:28









MBoMBo

48.9k23050




48.9k23050













  • Sounds reasonable. Thanks for the help mate

    – Giebels2609
    Nov 25 '18 at 18:06



















  • Sounds reasonable. Thanks for the help mate

    – Giebels2609
    Nov 25 '18 at 18:06

















Sounds reasonable. Thanks for the help mate

– Giebels2609
Nov 25 '18 at 18:06





Sounds reasonable. Thanks for the help mate

– Giebels2609
Nov 25 '18 at 18:06





Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

Refactoring coordinates for Minecraft Pi buildings written in Python