Notifications
Clear all

[Closed] Point3, Offset from Center of Face, along same Plane?

Hello again,

I’ve been thinking about this problem for a little bit now, and maybe it’s too complex for me to figure out or bother with.

I’m trying to figure out how to Translate a % like 25% into Mxs, so that I could say, take the Center of a Face (Point3), and give me another Point3 along the same plane, 25% offset from the Center of the Face. But 25% would be in consideration to the Face Area.

So if you did 50% offset in X+ for example, it would end up on the edge of the face.

Does this make sense, and how complex would this be… : \

Thanks!

Matt

5 Replies

Positions in the plane of the face can best be expressed using Barycentric coordinates.
If you look at the Attachment constraint, it kind of gives you a feeling of how that would work.

Much more difficult is to define what X and Y would be within the plane of the face. What do YOU consider +X in the plane of the face? The Z is obviously the face normal, but the other two axes could be arbitrary. You could assume ANY of the 3 edges to be X, or the vector connecting the face center with any of the vertices, or with the center of any of the edges…

I’ve been thinking this morning, and I’m going to do some tests quick…

But, basically, I have a 2D UI, and u can click inside a little 100×100 box, and where u click, a little dot moves. So right now I am calculating the % the dot is offset from the center pos.

But I just realized, couldn’t I take the Center Pos, take the Offset Pos, then create a Vector based on those? Then just offset in that direction?

Thanks!

I think I’ve almost got it.

Right now, the main thing I need to do is get a 2D Vector Direction from a pair of 2D Points, then align it so that the Local Z of the vector is aligned to a Face Normal, but the X/Y are more or less the same from the 2D Vector.  

I have it working in Max, when I use a Point aligned to a planes Local Z, I can move it around on the face, and I get the offset from the Center that I want. I’m generating a Direction though from the Face Center and the Point positions. So obviously a 2D Vector wouldn’t work the same, unless it’s orientation was planar to the Face Surface.

Edit: It looks like I got it! Or at least something closer now. Its still not quite right, but isn’t too bad. It mainly fails when the selected object is rotated, then some of my calculations are offset in the X/Y Plane. So instead of being in the corners of a face, my other objects are going outside of the face bounds.


 local faceCent = faceCenter obj face
   local area1 = faceArea obj face
 						
   local offsetBounds = sqrt area1
    local offsetPercentX = (offsetBounds * faceOffsetX)   --Percent is/will be Calcuated from UI in 2D.  
 
 local offsetPercentY = (offsetBounds * faceOffsetY)  * -1 --Face Offset calculated by subtracting the center of a 2D Box from a 2D Point, then * 0.01 to get an offset
 								
    local theNorm = theNormal obj face
 								
  local theType =  (execute (toLower propagation)) 
  local theObj = theType (getNodeByName objectPlace)
   append objectPlacer_PreviewObjects theObj
 
  theObj.pos = faceCent
   theObj.wirecolor = theColor
 									
   theObj.dir = theNorm
 								
    --Move Object in Direction
  in coordsys local  move theObj [offsetPercentX,offsetPercentY,0]
 								
  theObj.transform = (Matrix3 [theObj.scale.x,0,0] [0,theObj.scale.y,0] [0,0,theObj.scale.z] theObj.pos)

Edit: I think the main issue is the Quadrants. When selecting faces in Local transform, the X/Y is flipped as I knew, but the X/Y can also get skewed into 45 angles it looks like, so that would make sense why it offsets.

It’s not a huge deal, but it would be nice to be able to correct that somehow in my code.

Updated the Preview Post with my findings. Bump!