views:

243

answers:

3

Hi -

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.

Thanks,

--Roy

A: 

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)".

ChrisW
+1  A: 

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?

Thanks ChrisW + zekian. I follow what you are both saying. I found this interactive trig calculator after posting my question and am starting to get a handle on how to approach this. I'll have to do some translation of say bitmap data so that 0/0 is at the center of the image.And then figure out how to translate radians into discrete steps (stepper motors move in + or - n steps). Might be a bit of trial and error there - number of steps a ring can move in it's range of motion (say -45 degrees to 45 degrees) and then determine the number of steps per radian - something like that.thanks/Roy
Roy Pardi
Oh - meant to add the link to the trig calculator:http://www.visualtrig.com/Default.aspx
Roy Pardi
Radians are easily converted to degrees (I presume you know how many degrees each motor step is), to convert radians into degrees, we times them by 180 and divide by pi. So to get the XAxis in degrees you would do arcsin( X / sqrt(X² + Z²))*180/3.141592Also Z could be used to affect the scaling of your drawing, just thought I would let you know in case you didn't realise.If your curious, about how I came to the equations I gave you, I'll happily explain with the aid of a diagram.
A: 

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.

Dour High Arch
If you look at the movie it seems that he'll be painting with a laser rather than a physical brush.
ChrisW
Yeah - I'll be using an ink "jet" (solid stream, high pressure, controlled by a solenoid valve) at the center of the smallest ring.I have another machine I'm working on - more traditional X/Y plotter - and the programming for that is pretty straight forward (though precision + resolution = motor control has been a bit of a challenge.Some images here:http://roypardi.com/dp/
Roy Pardi
OK, I did not see the laser spot in the movie at first and I now see what you're talking about. I will leave my answer here though as a warning to others to investigate before posting.
Dour High Arch