THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/10/2011 at 20:11, xxxxxxxx wrote:
Cinema 4D Version: 13
Platform: Windows ;
Language(s) : C++ ;
I was wondering if someone could help me figure this problem out. I am creating a spline, and have all of the points of my spline and I place those points a certain distance away from the previous point. I would like to place on point at world center and then place one point above that at 100 above world center, which is easy, but then I would like to place one 100 away from the second point but at an angle of 45 degrees from the first line. Can anyone think of a formula that I can use to determine where the third point should be placed is I want it to curve away from the original line by 45 degrees?
So I want my spline to look like this.. :
The vertical line would be made of two points and the tilted line would also be two points making a total of 3 points and 2 segments. The second segment would be rotated about the z axis to lean 4d degrees to the right . Any ideas on how to achieve this?
On 25/10/2011 at 20:29, xxxxxxxx wrote:
Well, it is simple vector math.
First get a normalized direction vector that represents the angle you want. An angle that is 45º in the upper right quadrant of the XY plane would be a normalized direction vector of:
Vector directionV = Vector(0.707, 0.707, 0.0);
Then your formula for finding the next point 45º from the last vertical point (pt2) would be:
pt3 = pt2 + directionV * 100;
On 26/10/2011 at 05:28, xxxxxxxx wrote:
Thanks Dan, so for the direction vector, is the .707 the degrees in radians?
On 26/10/2011 at 05:47, xxxxxxxx wrote:
On 26/10/2011 at 05:50, xxxxxxxx wrote:
Actually, it's simply a normalized vector (length =1) at 45º.
If you look at an X,Y graph, a line drawn on that graph representing 45º would have an equal X and Y value. The X, Y and the 45º line will make a right triangle, with the line being the hypotenuse. So we use the sin and cos to figure the X and Y values if the hypotenuse is 1 (normalized) :
X = cos(45) * 1
Y = sin(45) * 1
On 26/10/2011 at 05:59, xxxxxxxx wrote:
okay so if I want to use a different angle than 45 I simply do :
x = cos(angle) * 1
y = sin(angle) * 1
to get my direction vector then perform the formula mentioned above?
thanks again guys
On 26/10/2011 at 06:05, xxxxxxxx wrote:
Yes, as long as you're restricting that to the XY plane.
On 26/10/2011 at 06:12, xxxxxxxx wrote:
Or it might be easier for you to build a rotation matrix using HPBToMatrix() and then use the X axis component of that matrix, which should be normalized.
Remember to rotate the X axis 45º and keep it on the XY plane, you'd rotate the matrix on the Z axis.
So, your HPB vector would be:
Vector angle = Vector(0.0, 0.0, 0.707);
On 26/10/2011 at 06:17, xxxxxxxx wrote:
so how does this change if I want to rotate a certain degree along any arbitrary axis? So if it wasn't restricted to the xy axis but any random 45 degree angle? thanks so much by the way. You are helping me a ton.. I have been studying trigonometry more lately but still need to lean more. Lol
On 26/10/2011 at 14:29, xxxxxxxx wrote:
Okay how would I set the normal of the point to face in the direction of angle I gave.. So that I can get this effect...
Ultimately I want to curve the spline, so I want to draw a point, then draw the next point a certain angle and distance away from the previous point, then draw the next point a certain distance and angle away from its previous point, etc.. So that I get a curve over the points. I want to do this manually..
Thanks in advance. Shawn
On 26/10/2011 at 15:00, xxxxxxxx wrote:
Well, as I suggested, using the HPBToMatrix() function is probably the easiest to understand. If you keep track of your previous matrix it will be simple to do this:
angleMatrix = previousMatrix * HPBToMatrix(angle);
previousMatrix = angleMatrix;
A matrix times a rotation matrix will rotate that matrix by the amount of rotation in the rotation matrix. But also remember that matrix multiplication is not commutative. The rotation matrix must be on the right side of the existing matrix:
finalMatrix = existingMatrix * rotationMatrix
On 26/10/2011 at 15:06, xxxxxxxx wrote:
Thanks Dan.. I had just sent you an email before I saw this post so sorry for the double question.. Thanks
On 26/10/2011 at 15:24, xxxxxxxx wrote:
okay so after I make the Matrix do I set the point vector equal to
points = points + m.v3 * length
Here's what i am trying.. but it's not right,.,, lol
Vector A = Vector(0.0, 0.0, Rad(angle));
//Vector dirV = Vector(x, y, z);
Matrix m = HPBToMatrix(A, ROTATIONORDER_XYZGLOBAL);
points[i] = lastpos + m.v3 * segSize;
On 26/10/2011 at 15:31, xxxxxxxx wrote:
Maybe this file will help explain it:
On 26/10/2011 at 16:34, xxxxxxxx wrote:
Yes that helps a lot thank you. Sorry I meant to reply quicker but then my mother skyped me HAHAHA.. Thanks Dan.