Actually, I have designed a C# program That controls the CNC machines, For example, we can take UGS, There is much software out there but I need to create this in C#. The Only thing I am suffering here is the 3D coordinate system. How to create the Axis diagram in 3D. Example: Planet Cnc's "Cnc USB Controller" I want to create this software in C#.
-
1`public record Vector3d(float X, float Y, float Z);` - not really sure if you are asking for something beyond that... Some [edit] may help to narrow down question to on single coding problem and make question more answerable... – Alexei Levenkov Oct 20 '21 at 03:23
-
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Oct 20 '21 at 06:43
-
I would suggest checking out helix 3d, they have some samples on how to setup a 3D view. But your question is quite unclear. I would suggest doing some basic research on how 3D graphics in c# work, and limit the question to a particular problem. – JonasH Oct 20 '21 at 06:46
1 Answers
I'll answer as best I can but you should consider defining the scope of what you want to achieve i.e. if you want just a coordinate system or a UI to go with it like UGS.
The best way to make just a coordinate system is to define all your data that you need like position, rotation, feed, rapid, offset, etc. then wrap those all in a class for the machines state with methods to help you manipulate the data.
Example
public struct Vector3
{
public float x,y,z
}
public struct Rotation
{
public float x,y,z //Or whatever your machine uses, the 5 axis at my work is v,w for rotation.
//I recommend leaving it as x,y,z though cause it will make it more robust as you
//can use the same code on different machines by interpreting the values differently later on.
//Alternatively you could use a Quaternion if need but most machines interprat eular angles just fine without gimble lock.
}
//only if you need scale. stay away from this if you can help it, it will make zeroing harder because you will have to use matrix math to make the position and rotation work properly with it(I could be wrong about that though).
public struct Scale
{
public float x,y,z
}
public struct Transform
{
public Vector3 position;
public Rotation rotation;
}
//then create a class to define the state of the machine.
public class MachineState
{
public bool rapid = false;
public bool feed = false;
public bool flood = false;
public bool mist = false;
public Transform transform;
//An example of a method to manipulate the data.
public Vector3 CalculateOffset (Vector3 offsetPosition, Vector3 offset)
{
//Add your offset logic here.
}
}
If you need a UI as well then I recommend .net MUAI or Windows Forms, either of those should make it straight forward to create a UI to consume this data, as well as adding a 3D view and anything else you can think of.
.Net MAUI: https://learn.microsoft.com/en-us/dotnet/maui/what-is-maui
Windows Forms: https://learn.microsoft.com/en-us/dotnet/desktop/winforms/?view=netdesktop-5.0
I hope this helps set you on the right track but also take everything I said with a grain of salt because I have never made a program that manipulates cnc machines before.
I just operate and do data analysis on them. I do have a lot of knowledge with coordinate systems though because I used to be a game developer.

- 21
- 7
-
1I would be super-scared of using a euler angles that may be interpreted differently in different environments. I would strongly argue for specifying which variant is used. Or just use quaternions and let something else worry how to translate it to rotations in the machine. Also, the system.Numerics library provides just about all the basic classes for 3D vectors and transforms. – JonasH Oct 20 '21 at 06:55