Getting normal to cylinder face
-
Hi there,
I am having some trouble with some code I'm writing and was wondering if there was a simple solution that I'm unaware of.
My aim is to find vector the normal to a cylinder face (where the cylinder has beeen 'stored' as a group) and from that, work out the orientation of the cylinder group. So far, I have been able to do this for a cylinder which I created. However if I rotate the cylinder and perform the same operation, the normal vector does not change with the rotation i.e. if I create a cylinder aligned along the z axis - circle.normal will always give (0,0,1) despite any rotation i perform on the group.
I assume the information about the rotation is stored somewhere and from this I could work out the cylinder orientation - but I'm at a loss to work out how to do this.
Any help with this would be greatly appreciated.
-
Try
adjusted_normal=face.normal.transform!(group.transformation)
where 'group' is the container of the circle-'face' on the end? -
Cheers TIG, that did the trick.
-
Just answered my own question, transformation is relative to the parent.
Here's some more compact code:
normal = entity.normal for i in (0..(path_to_entity.length-2)) do e = intersect_path[i] normal = normal.transform! (e.transformation) end -
@tig said:
Try
adjusted_normal=face.normal.transform!(group.transformation)
where 'group' is the container of the circle-'face' on the end?Sorry for digging up an old topic, but will this work with nested groups/component instances?
normal = entity.normal i = 0 path_to_entity.each {|entity| i +=1 break if i >= path_to_entity.length normal = normal.transform! (entity.transformation) }Or does transform represent a transformation from the models axes? (ie, just require
normal = normal.transform! (entity.transformation)Just for background, I'm trying to get a model based vector of the face normal as in peterjohnson84's example
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better đź’—
Register LoginAdvertisement