I have a project in which i need make a matlab based simulation of a robotic arm.
img http://img845.imageshack.us/img845/4512/l5mx.png
The first part sits in the origin, and can rotate around the Z axis in the world coordinate system. This joint is called joint1. The next joint, joint2 is displaced 0.8m in the Z direction of the coordinate system of part 1. It will rotate around the Y axis of the coordinate system of part2. Joint3 is displaced 0.6m in the Z direction of the csystem of part2. It will rotate around the y axis of the csystem of part3. The end of part3 is displaced 0.7m in the Z direction of csystem of part3.
Now, lets try to do some matrices of this. I'm quite sure i'm doing something wrong with these. The coordinates will be in homogenous form, so v = [v,1].
T_Wto1 = [cos(alpha(1)), -sin(alpha(1)), 0 , 0;
sin(alpha(1)), cos(alpha(1)), 0 , 0;
0, 0, 1 , 0.8;
0, 0, 0, 1];
T_1to2 = [cos(alpha(2)), 0, sin(alpha(2)), 0;
0, 1, 0, 0;
-sin(alpha(2)), 0, cos(alpha(2)), 0.6;
0, 0, 0, 1];
T_2to3 = [cos(alpha(3)), 0, sin(alpha(3)), 0;
0, 1, 0, 0;
-sin(alpha(3)), 0, cos(alpha(3)), 0.7;
0, 0, 0, 1];
For alpha(1) = 0, alpha(2) = alpha(3) = pi/2
First of all. If i use p1 = T_Wto1*[0,0,0,1]', i get [0,0,0.8,1]', so far so good. Then, T_1to2*[0,0,0.8,1]' gives [0.8,0,0.6,1]' (it is now displaced 0.8 in the X direction, which is really 0.8 in the Z direction, because of the rotation). Now, say that i want to transform this back to world coordinates. It should say [0.6,0,0.8], but i'm unsure on how to do that. If you just take the inverse of the matrix T_Wto2 (a product of T_Wto1 and T_1to2), you just get the origin [0,0,0,1] back. What are you supposed to do to make it back into world coordinates again?
Also, are the transformation matrices correct?
Related
How can I flip the +/- direction of a single axis in a pose?
i want Z to go upwards, not downwards..
Thanks
If you want the z-axis goes upwards, you should apply a composing between that pose you're getting and another pose who has 180° (positive or negative) in the X or Y axis (any of both will work). If I try to emulate you posing, you should have something like next:
If you apply the composing I just said, you will get something like next:
The second image was achieved with a 180° rotation over X-Axis. The code was just:
create_pose (0, 0, 0, 0, 0, 0, 'Rp+T', 'gba', 'point', yourPose)
create_pose (0, 0, 0, 180, 0, 0, 'Rp+T', 'gba', 'point', transformationPose)
pose_compose (yourPose, transformationPose, transformedPose)
Remember, you would have 4 options for achieving the purpose of having Z-Axis upwards; +180° rotation in X-Axis, -180° rotation in X-Axis, +180° rotation in Y-Axis and -180° rotation in Y-Axis.
I have below information like gravity, thrust, my initial x, y and initial velocities. How do I calculate
1. Time to reach the top of the projectile 2. Horizontal displacement during that time
"grav": 0.7,
"thrust": 10.5,
"me": {
"x": 0,
"y": 180,
"vx": 4,
"vy": 0
}
So far I have tried this formula to calculate vertical displacement (reference here)
For Horizontal displacement, I used t*vx0;
If initial vertixal velocity(vy) is zero, assuming gravity is on the y direction, then how is the object ever going to go up to reach the top?
Generally thrown objects reach the top when vy = 0 when t= vy/grav, and x position = t * vx.
I am learning to work with unity now and I noticed one error. I am working with 2D and have two box colliders.
One of them is:
Size : X = 8, Y = 0.3
Center: X = 0, Y = 4.9
The Other one is
Size : X = 3, Y = 0.6
Center: X = 0, Y = 3.95
So from this information we can see that the gap between those two colliders is 0.5, but a rigidbody with a circle collider with a radius of 0.25 is not able to move through that gap, it gets stuck.
Maybe there's something I don't know about the way colliders work and you could shed some light.
I am trying to skew a rectangle so the two vertical sides are slanted but parallel and the top and bottom are horizontal.
I am trying to use CGAffineTransform and have found this code but I am not figuring out what to put in the various parts.
imageView.layer.somethingMagic.imageRightTop = (CGPoint){ 230, 30 };
imageView.layer.somethingMagic.imageRightBottom = (CGPoint){ 300, 150 };
#define CGAffineTransformDistort(t, x, y) (CGAffineTransformConcat(t, CGAffineTransformMake(1, y, x, 1, 0, 0)))
#define CGAffineTransformMakeDistort(x, y) (CGAffineTransformDistort(CGAffineTransformIdentity, x, y))
although this is said to be easy I don't know what to put in the different places.
I assume image view would be my image that I want to change however what goes into somethingMagic. and imageRightTop and imageRightBottom.
Also how do I define t.
If there is a more thorough explanation I would appreciate it since in most cases I found only this as the explanation of what to do to skew a rectangle.
Thanks
Let's assume you have a variable named imageView holding a reference to your UIImageView.
I wrote a little sample to demonstrate how you could get this behavior. What this code does is creating a new CGAffineTransform matrix. This matrix has the same values as the identity transform matrix with one exception: the value at location [2,1]. This value is controlled by the c-parameter of the CGAffineTransformMake-function and controls the shearing along the x-axis. You can change the amount of shearing by setting shearValue.
The code:
Objective-C
CGFloat shearValue = 0.3f; // You can change this to anything you want
CGAffineTransform shearTransform = CGAffineTransformMake(1.f, 0.f, shearValue, 1.f, 0.f, 0.f);
[imageView setTransform:shearTransform];
Swift 5
let shearValue = CGFloat(0.3) // You can change this to anything you want
let shearTransform = CGAffineTransform(a: 1, b: 0, c: shearValue, d: 1, tx: 0, ty: 0)
imageView.transform = shearTransform
And here's what the shearTransform-matrix looks like:
[1 0 0]
[0.3 1 0]
[0 0 1]
I need to visualize a playing field for a robot game. Unfortunately, the game uses a right handed coordinate system, with the y axis pointing up.
Is there a way to adjust the cairo context of a drawing area so that it matches this coordinate system?
I can scale, translate and rotate, but I cant find a way of switching the y axis orientation, which would be more convenient compared to converting all coordinates individually.
Thank you for any input!
You are allowed to define every field in a cairo_matrix_t:
cairo_matrix_t flip_y;
cairo_matrix_init(&flip_y, 1, 0, 0, -1, 0, 0);
cairo_set_matrix(cr, &flip_y);
Just remember how the trasformation is applied:
x_new = xx * x + xy * y + x0;
y_new = yx * x + yy * y + y0;