PDA

View Full Version : Getting the angle of two attached faces


josiah
02-17-2004, 06:46 PM
Hello everyone.
I am working on a script that will select the edges of a mesh whose attached faces fall below a certain angle threshold. If the two faces are say, less than 10 degrees in their hinge angle, the edge will be selected.

The problem I am having is getting the angle between two faces attached to a common edge.

Heres an excerpt of the script:

////////////////////////////////////////////////
local edge_selection = #{}
local base_obj = $.baseobject
local num_edges = polyop.getNumEdges base_obj

for f = 1 to num_edges do
(
local edge_faces = polyop.getEdgeFaces base_obj f
local faces_angle = polyop.getFacesAngle edge_faces
if faces_angle < 10 do edge_selection[f] = true
)
///////////////////////////////////////////////

Of course, there is no "polyop.getFacesAngle", that returns the angle between two faces, but this illustrates what I am trying to do.

So how can I do this? Any Ideas are appreciated!

Thanks!

LFShade
02-17-2004, 06:59 PM
Get the normal for each face and compare the angle between them. If you run into trouble with that I can help, but I'm all out of time for an example right now.

RH

josiah
02-17-2004, 07:54 PM
Thank you so much! Ok heres the whole thing, seems to work!

////////////////////////////////////////////
macroscript Select_Low_Angle_Edges

(
on isEnabled return
(
selection.count == 1 and classOf selection[1].baseobject == Editable_Poly
)
on execute do
(
local edge_selection = #{}
local base_obj = $.baseobject
local num_edges = polyop.getNumEdges base_obj
local edge_faces = #() -- array to hold selected edge faces

for f = 1 to num_edges do
(
edge_faces = polyop.getEdgeFaces base_obj f
local face_angle1 = polyop.getFaceNormal base_obj edge_faces[1]
local face_angle2 = polyop.getFaceNormal base_obj edge_faces[2]
local faces_angle_diff = (acos (dot face_angle1 face_angle2))
if faces_angle_diff < 5 do edge_selection[f] = true
)

polyop.setEdgeSelection base_obj edge_selection
max modify mode
modPanel.setCurrentObject base_obj
subobjectlevel = 2
)
)
////////////////////////////////////////////

Thanks!

CGTalk Moderation
01-17-2006, 11:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.