实际上,我已经设计了一个控制数控机床的C#程序,例如,我们可以使用UGS,有很多软件,但我需要在C#中创建它。唯一让我痛苦的是3D坐标系统。如何在3D中创建轴线图。例如: Planet Cnc的"Cnc USB控制器“我想在C#中创建这个软件。
发布于 2021-10-20 04:45:01
我将尽我所能地回答,但你应该考虑定义你想要实现的范围,例如,如果你只想要一个坐标系或一个UI来配合它,比如UGS。
创建坐标系的最好方法是定义您需要的所有数据,如位置、旋转、进给、快速、偏移等,然后将所有这些数据包装在机器状态的类中,并使用方法帮助您处理数据。
示例
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.
}
}如果你也需要一个UI,那么我推荐Windows或.net Forms,它们中的任何一个都可以直接创建一个UI来使用这些数据,以及添加一个3D视图和任何你能想到的东西。
.Net毛伊岛:https://docs.microsoft.com/en-us/dotnet/maui/what-is-maui
Windows窗体:https://docs.microsoft.com/en-us/dotnet/desktop/winforms/?view=netdesktop-5.0
我希望这能帮助你走上正确的道路,但也对我所说的一切持保留态度,因为我以前从来没有编写过操纵数控机床的程序。
我只是对它们进行操作和数据分析。我确实有很多关于坐标系统的知识,因为我曾经是一个游戏开发人员。
https://stackoverflow.com/questions/69639562
复制相似问题