Jump to content
  • Advertisement
Sign in to follow this  
giugio

extrusion and dir

This topic is 2117 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello.
I have a 2d shape and i create a 3d extrusion on direction 0 0 1( i must do the extrusion on z axis for personal stuff, i can't use directly the extrusion direction).
Now i wish rotate the 3d extrusion solid by the extrusion direction.
How i can create a rotation matrix based on the extrusion direction?
I must first find the extrusion angle? but in which plane i must calculate the angle and in which plane is the  extrusion axis?
this is an image

 

image.png

 

thanks.

Share this post


Link to post
Share on other sites
Advertisement

Not sure what you are trying to accomplish, but it seems to me you are extruding a shape along the z-axis and want to then orient it in the direction of some secondary vector? Does the image show a top-down view of what you are trying to do? If you want to rotate around the Y-axis on the XZ-plane, you can use the following matrix (with v being the normalized "extrusion direction"):

 

[v.z, 0, -v.x]

[0, 1, 0]

[v.x, 0, v.z]

Share this post


Link to post
Share on other sites

thanks.
but my problem is that the dir vector can be in any direction, also can have a rotation component in all the planes, es 30° in xy plane, 12 ° in yz , 24° in xz plane ecc....
i must find a rotation matrix for all the rotation components in all the planes for the dir vector and i not know how.
thanks.

Share this post


Link to post
Share on other sites

Something is missing, I believe. The spaces in which the original shape and the extrusion direction are given must be identical at the moment of extrusion. You cannot pick different spaces and rely on a rotation to correct the situation. That means, you must have already done a transformation on the 2D shape before extrusion, and this transformation has mapped the original extrusion axis to (0,0,1). Hence, applying the inverse of said transformation on the extrusion's result would do the trick.

Edited by haegarr

Share this post


Link to post
Share on other sites

My understanding is that the z-axis transformed by the matrix becomes the extrusion vector.

 

If you want a matrix that is the result of a series of rotations around the z (roll), x (pitch) and y (yaw)-axes: http://www.flipcode.com/documents/matrfaq.html

This page also shows how to set up a matrix that rotates the extrusion from its original z-orientation towards a second vector on the plane formed by the two vectors.

Share this post


Link to post
Share on other sites


My understanding is that the z-axis transformed by the matrix becomes the extrusion vector.

I would say: The z axis w.r.t. the actual extrusion space (i.e. those where the extrusion is performed) should be transformed into the extrusion axis in specification space (i.e. those where the demanded extrusion axis is specified), and the already generated 3D extruded shape should undergo the same transformation.

 

However, here is already a problem. Assume a square in the xy plane. Extrude it in z direction. Apply a rotation so that the z axis becomes the specified extrusion axis. The resulting shape will be a coboid, all angles between neighboring faces being 90 degree. Now think of the shape that would result if the same square is extruded along an axis titled by e.g. 45 degree in x direction. Those shape will be another one. To overcome this problem, one has to transform the square so that the orientation of the square relative to the extrusion axis is the same in this space as it was in the specification space. The transform applied, however, is actually the inverse of those where the OP is looking for. So it seems me that either the extrusion is not done correctly, or else the solution is indirectly already given. We need some more information on this.

 


This page also shows how to set up a matrix that rotates the extrusion from its original z-orientation towards a second vector on the plane formed by the two vectors.

Well, this solution is one possibility of infinitely many solutions; but it is one, correct.

Share this post


Link to post
Share on other sites

thanks guys, very kind of you for your help.
now i wish express better my problem:
1)i have a 2d shape that i must extrude
2)i have an extrude direction that can be any normalized dir.
3)the 2d shape in 3d is flat, i must rotate it before extrude it and i must rotate ortogonal at the extrusion direction but how?

in the first 2 topics i would rotate the extrusion of a flat 2d shape in the z axis, but i understand haegarr and i would rotate the 2d shape before extrude the solid.
is correct?
But i not understand haegarr about the inverse matrix, can you explain me better this trick?

now:
1)is better do the extrusion of the 2d shape on the z axis then rotate the solid by the direction of the extrusion?
2)or is better rotate the 2d shape in 3d then do the extrusion by the extrusion direction?

these are the questions, how i can do that?
eppo i don't find your advice in your link.
thanks.

 

sorry, the image :

shape.png

Edited by giugio

Share this post


Link to post
Share on other sites

hello eppo i find now your solution, is the :
Q39. How do I generate a rotation matrix to map one vector onto another?

then i can find the rotation axis(with the cross product) and the angle(with dot product) and use the generic formula for rotate around an arbitrary axis?
is correct?
and, in base at my last post i can rotate also the 2d shape in 3d with the same process?

thanks, now i try
 

Share this post


Link to post
Share on other sites
Yes, correct. If you want more control over the roll of the orientation you can pre-multiply it with a rotation around the z-axis.
 
If you were to do the same in a 3D modeling app, you would likely first extrude the shape and then orient it, though it's possible to first rotate the 2D shape and then extrude it along the matrix' z-vector component.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!