Getting the angle of two attached faces

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  02 February 2004
Question Getting the angle of two attached faces

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!
__________________
Love All, Serve All, Forgive All.
 
  02 February 2004
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
__________________
Got Maxscript?
RHTools
 
  02 February 2004
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!
__________________
Love All, Serve All, Forgive All.

Last edited by josiah : 02 February 2004 at 09:28 PM.
 
  01 January 2006
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:50 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.