Problem with face.normal directions...help!
-
In the graph below I can work out if a face is normal is facing on the direction specified in the first four examples. But I don't know how to evaluate if a face normal is facing giving the directions specified in the last four graph examples. Any help will be Appreciated!


If my problem is not clear please let me know I will try to explain it better...cheers!
-
I think this might be it...Sorry not very good at math

Top Right = f1nx > 0 and f1ny > 0
Top Left = f1nx < 0 and f1ny > 0
Button Right = f1nx > 0 and f1ny < 0
Button Left = f1nx < 0 and f1ny < 0
-
I'm not quite sure I understand, but I think I might have something helpful.
Find the dot product of the face's normal and the x_axis. If its a positive number, then the face normal is in the positive x range. Do the same for the y and z (if you need z). Try this code snippet, it will tell you if the face normal is pointing in a positive or negative x,y,z direction. Or it will tell you if the face normal is perpendicular to the model x,y, or z axis.
face=Sketchup.active_model.selection[0] norm = face.normal dot_products = {} dot_products["x"] = norm.dot(X_AXIS) dot_products["y"] = norm.dot(Y_AXIS) dot_products["z"] = norm.dot(Z_AXIS) dot_products.each do |key, value| case when value < 0 puts "#{key} direction is a negative direction" when value == 0 puts "#{key} direction is perpendicular to the #{key} axis" when value > 0 puts "#{key} direction is a positive direction" end end -
Thanks Chris Fullmer your example does the job as well.
Here is another example that will select faces that are pointing to the top right...
model = Sketchup.active_model sel = model.selection ents = model.active_entities faces = ents.grep(Sketchup;;Face) faces.each do |face| f1nx = face.normal.x f1ny = face.normal.y #Face looking top right if f1nx > 0 and f1ny > 0 sel.add face end end -
That image in the OP isn't loading for me...
-
now?
-
nope, not yet. It never showed for me either, I had to click on it to follow the link.
-
No.
The image links aren't working...



Above is http://s11.postimg.org/z4m5fepiq/question.jpg NOT these...
http://s11.postimg.org/jj4tvgdki/question.jpg]
http://s11.postimg.org/ohsc9zhdd/question.jpg -
I see it. NA NA NA-NA NA
-
Back to the question...
NorthEast Quadrant: normal.y>0 normal.x>0
SouthEast Quadrant: normal.y<0 normal.x>0
SouthWest Quadrant: normal.y<0 normal.x<0
NorthWest Quadrant: normal.y>0 normal.x<0As you said:
Due North: normal.y==1 normal.x==0
Due East: normal.y==0 normal.x==1
Due South: normal.y==-1 normal.x==0
Due West: normal.y==0 normal.x==-1Exactly Vertical: normal.z==0
Upwards Facing: normal.z>0
Downwards Facing: normal.z<0
Exactly Up: normal.z==1
Exactly Down: normal.z==-1
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