cgijedi Posted April 27, 2005 Share Posted April 27, 2005 Hi all, I'm trying to get the centoid of a sop using the centroid function. In help, The syntax is as follows: centroid(SOP, type) it then goes on to describe the types as eithr D_X, D_Y, D_Z. does this mean centroid("/obj/geo1/sopName", D_X) would return the X component of the centroid for that SOP? I don't seem to be getting a result for this or when i subsitute TX, or just X in for D_X. What am I obviously missing here? thanks ~cgijedi Quote Link to comment Share on other sites More sharing options...
Jason Posted April 27, 2005 Share Posted April 27, 2005 Hi there, D_X is like an enumeration for the index into the position - which is a float[3]. You can use the (lexical) enumerator OR the numeric value it represents: D_X is 0 D_Y is 1 D_Z is 2 So no other enumerations are defined for the centroid function. Does that make sense? Hope it helps, Jason Quote Link to comment Share on other sites More sharing options...
cgijedi Posted April 27, 2005 Author Share Posted April 27, 2005 Yes, that makes total sense. I'll give it a shot. danke~ -Andrew Quote Link to comment Share on other sites More sharing options...
grasshopper Posted April 27, 2005 Share Posted April 27, 2005 Another way to go when finding the centroid of a SOP is to append a bounds SOP to calculate a bounding box and then an add SOP which adds a single point set to the centroid using the variables: $CEZ $CEY $CEZ. You can then reference the centroid from elsewhere with point expressions that reference the centroid. The centroid will be the 9th point in the list of points in the add SOP as the other 8 points are the corners of the bounding box but you need to refer to point 8 rather than 9 as counting starts at 0. That is, point ("/obj/geo/add",8,"P",0) can be used to get the X value, point ("/obj/geo/add",8,"P",1) gets the Y and point ("/obj/geo/add",8,"P",2) gets the Z. Hope hat makes sense! john. Quote Link to comment Share on other sites More sharing options...
edward Posted April 28, 2005 Share Posted April 28, 2005 In case anyone is wondering why would anyone want to do it in such a convoluted manner, I'll defend john. It might be more speed efficient if you have lots of centroid expressions referencing the same geometry because it would then recompute it each time whereas the SOP approach will only do it once. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.