Rounding a 3D Edge

55 views
Skip to first unread message

Kevin C. Burke

unread,
Oct 12, 2020, 2:04:34 PM10/12/20
to Python Programming for Autodesk Maya
Hello,
I'd like to procedurally bevel an edge loop for a polygon object plugin that I am making. I am seeking help in coding an algorithm that does this using Python (not using any API method like polyBevel).

So far in my research, it appears to be a matter of mathematically generating an arc of points between two points [P1, P2] based on their distance from a third angular point [P] and a radius.
B1ifD.gif

Bevel.gif

I found this post from Stack Overflow about rounding corners using the C# & math. In an attempt to understand it, I created this, my translation to Javascript & HTML Canvas. I'm unable to get the arc of points to meet at the right positions consistently though as I do not entirely understand the math.

Can anyone provide guidance for generating this arc of points based on three points please? Thank you!

Kevin C. Burke

unread,
Oct 12, 2020, 4:59:21 PM10/12/20
to Python Programming for Autodesk Maya
I have been able to find points A, B, & C in this image:
Start_and_End_Angle.jpg 

Here is my pymel that creates locators for V1, V2, & V3, then solves for A, B, & C.:
import pymel.core as pm,math
import pymel.core.datatypes as dt

r = 1.5 #radius
V1 = dt.Vector(1, 2, 0)
V2 = dt.Vector(2, 6, 0)
V3 = dt.Vector(7, 7, 0)
V1L = pm.spaceLocator( p=V1, n="v1", a=True )
V2L = pm.spaceLocator( p=V2, n="v2", a=True )
V3L = pm.spaceLocator( p=V3, n="v3", a=True )
a = V2-V1
b = V2-V3
a.normalize()
b.normalize()
halfang = math.acos((a.dot(b)))/2
ab = (a+b)/2
ab.normalize()
A = V2 - r/math.tan(halfang)*a;
B = V2 - r/math.tan(halfang)*b;
C = V2 - r / math.sin(halfang) * ab

AL = pm.circle( c=A, r=0.3, nr=(0, 0, 1), n="A" )
BL = pm.circle( c=B, r=0.3, nr=(0, 0, 1), n="B" )
CL = pm.circle( c=C, r=0.3, nr=(0, 0, 1), n="C" )

I am seeking help in determining the positions of a specified number of points in the arc labeled 'Arc B' between A & C.


Marcus Ottosson

unread,
Oct 13, 2020, 2:48:11 AM10/13/20
to python_in...@googlegroups.com
Just wanted to chime in and say thanks for sharing, love the illustrations.

I wonder if catmull-clark is relevant here? I came across this video recently which covers implementation in a C-like language (Houdini's VEX).


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/fe4ad6be-9f0c-418f-99f8-3968f6a6e0dan%40googlegroups.com.

vince touache

unread,
Oct 13, 2020, 8:33:30 AM10/13/20
to Python Programming for Autodesk Maya
this is exactly what I had in mind. Catmull-clark will give you a volume loss, but in this case, it might be just what you're looking for. 

Kevin C. Burke

unread,
Oct 13, 2020, 2:08:03 PM10/13/20
to Python Programming for Autodesk Maya
Thank you both for the replies and thanks Marcus for the kind words. In this case, I'll be bevelling just one point in an edge loop of my polygon object so Catmull-Clark wouldn't work. Thanks for the video though: I learned a lot!

It would be great to get math help from the group on drawing points in an arc (Arc B in the above example) in the correct direction between the two points made by the cross product.

Thank you!

vince touache

unread,
Oct 13, 2020, 2:14:34 PM10/13/20
to Python Programming for Autodesk Maya
you can totally apply a catmullClark algorithm and keep the same number of subdivs, it's just a matter of "ignoring" the extra subdivs.
If you're not happy with this one, how about a simple laplacian? e.g. 
O = (P1+P2)/2
Then you get vector PO, and you multiply it by a user sigma value, depending how much you want to "smooth". E.g. sigma=0, P1'=O
Reply all
Reply to author
Forward
0 new messages