基于万向节的喷漆机的数学编程帮助

发布于 2024-07-19 14:08:23 字数 960 浏览 5 评论 0原文

我是一名艺术家,致力于建造各种计算机控制的机器。 我已经开始制作基于万向节的 XY 绘画机原型,并意识到所需的数学知识超出了我的能力范围。 我是一个足够好的程序员,但数学不强,尤其是。 3D 数学。

为了了解我需要做什么,查看装备可能会有所帮助:

早期原型:

http: //roypardi.com/gimble/IMG_2803.JPG

http://roypardi.com/gimble/IMG_2805.JPG

http://roypardi.com/gimble/IMG_2806.JPG

http://roypardi.com/gimble/gimbleSmall.MOV(小视频)

http://roypardi.com/gimble/gimbleLarge.mov(放大视频)

两个内环代表 X/Y 轴,由步进电机控制。 我希望能够同时使用光栅图像和矢量数据(gcode)。 因此,我需要能够根据我的数据在纸上/二维空间中找到一个点,并让万向节弄清楚它需要处于什么方向才能到达那里(即每个电机步进多少)。

我一直在寻找 2D > 3D 投影、欧拉角等,但我超出了我的能力范围。 任何指针、正确方向的推动或代码片段都将受到欢迎。 我能理解大多数编程语言。

I'm an artist involved with building various sorts of computer controlled machines. I've started prototyping a gimble-based XY painting machine and have realized that the maths needed are out of my reach. I'm a decent enough programmer but not strong in math- esp. 3D math.

To get a sense of what I'm needing to do, it might be helpful to look at the rig:

Early prototype:

http://roypardi.com/gimble/IMG_2803.JPG

http://roypardi.com/gimble/IMG_2805.JPG

http://roypardi.com/gimble/IMG_2806.JPG

http://roypardi.com/gimble/gimbleSmall.MOV (small video)

http://roypardi.com/gimble/gimbleLarge.mov (larger video)

The two inner rings represent the X/Y axes and are controlled by stepper motors. I want to be able to use both raster images and vector data (gcode). So I need to be able to address a point in 2D space on the paper/from my data and have the gimble figure out what orientation it needs to be at in order to get there (i.e. how much to step each motor).

I've been searching out 2D > 3D projection, Euler angles, etc. but I'm out of my depth. Any pointers, pushes in the right direction, or code snippets would be most welcome. I can make sense of most programming languages.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

素染倾城色 2024-07-26 14:08:24

我认为这是一个简单的问题 http://en.wikipedia.org/wiki/Trigonometry

假设从环的中心到纸上最近的点(我将其称为“原点”的点“O”)的距离是距离 X。

在 O 的正北面取另一个点 P,其与 O 的距离是 Y。

要绘制此点,您需要角度 alpha,使得 tan(alpha)=Y/X,即您可以使用公式“arctan(Y/X)”计算 alpha [arctan 有时也称为 atan]。 Arctan 是一个三角函数,我想您可能会在通用数学库的 API 中找到它的定义。

以上是最简单的情况。

我能想到的唯一另一种情况是 P 点不在正北。 假设它的距离不是正北,而是北边的距离为 Y1,东边的距离为 Y2。 解是两个角(两个环各一个角),其中一个是“arctan(Y1/X)”,另一个是“arctan(Y2/X)”。

I think it's a problem of simple http://en.wikipedia.org/wiki/Trigonometry

Let's say that the distance from the centre of your rings to the nearest point on the paper (which I'll call point 'O' for 'Origin') is distance X.

Take another point P directly north of O, whose distance from O is Y.

To paint this point, you need the angle alpha such that tan(alpha)=Y/X, i.e. you can calculate alpha using the formula "arctan(Y/X)" [arctan is sometimes also known as atan]. Arctan is a trignometric function, which I think you'll probably find defined in the API of a general purpose math library.

The above is the simplest case.

The only other case that I can think of is when the point P isn't due north. Instead of being due north, let's say that its distance is Y1 to the north, and Y2 to the east. The solution is two angles (one angle for each of two rings), one of which is "arctan(Y1/X)" and the other of which is "arctan(Y2/X)".

寂寞清仓 2024-07-26 14:08:24

也许我误解了,但我不相信万向节会做你想做的事。 万向节可以指向任何 3D 方向,但它不能移动到 3D 空间中的任意点。 如果纸的平面与万向节中的笔所扫过的体积相交,则笔可能能够画一个圆,但仅此而已。 即使画一个圆也不是确定的事情,因为在这种情况下,纸张也会与万向节环扫过的体积相交; 试图调整笔的方向会导致纸上出现一个圆环。

我认为你想要的是 绘图仪,而不是万向节。

Perhaps I misunderstand, but I don't believe a gimbal will do what you want. A gimbal can point in any 3D direction, but it cannot move to arbitrary points in 3D space. If the plane of the paper intersects the volume swept by the pen held in the gimbal, the pen might be able to draw a circle, but nothing more. Even drawing a circle is not a sure thing, since in this case the paper would also intersect the volume swept by the gimbal rings; trying to orient the pen would make a ring hit the paper.

I think what you want is a plotter, not a gimbal.

白云悠悠 2024-07-26 14:08:23

你制作的机器非常好,我希望这对你有用,我相信它是正确的。

在我看来,获得一个角度很简单,但另一个角度稍微难以想象,因为我们倾斜了它所转动的轴。

我将避免使用 tan,因为在编程时这可能会导致除以 0,这可能会令人沮丧。 Z 也是原点在纸张上方的高度。

YAxis = arcsin( X / sqrt(X² + Z²))

XAxis = arcsin( Y / sqrt(Y² + X² + Z²))

或者我们可以使用

XAxis = arcsin(Y / sqrt(Y² + Z²))

YAxis = arcsin( X / sqrt(X² + Y² + Z²))

另外,我非常想看这个绘图的视频(如果它有效的话)。

编辑:
经过思考后,我相信只有一种解决方案可行,这取决于哪个轴受到另一个轴的影响。 Y轴在中间还是X轴?

Very nice machine you have made, I hope this works for you I believe it is correct.

The way I see it, is to get one angle is simple, but the other is slightly harder to visualise as we have tilted the axis which it turns upon.

I'm going to avoid using tan, as when programming this could result in a division by 0, which could be frustrating. Also Z is going to be the height of the origin above the paper.

YAxis = arcsin( X / sqrt(X² + Z²))

XAxis = arcsin( Y / sqrt(Y² + X² + Z²))

or we could use

XAxis = arcsin(Y / sqrt(Y² + Z²))

YAxis = arcsin( X / sqrt(X² + Y² + Z²))

Also, I'd very much like to see a video of this plotting, if it works.

Edit:
After thinking about it i believe only one solution will work it depends on which axis is affected by the other. Is the YAxis in the Middle or the Xaxis?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文