Wow, this topic is moving fast now.
Ok, so it's cubic 4 X 4 Bezier Patch. (As can be seen).
The idea I had was to conform my surfaces(from the node editor) to be valid with your nice editing possibilities after baked down to Sketchup.
I've built a simple translation-Gizmo for moving points(must have that at least) but your editing abilities are way more advanced. More than I would need actually in my GUI, since mostly dependent on parameter values..
This would be at a later stage anyway. There is still plenty of Math to deal with
In all case.
Congratulations to this version! The Gizmo is spectacular.
BTW
I don't know if you are gonna continue updating this plugin, since focus is on the subdivision pligin. But if you do and stay with Beziers, have you had a look at the power basis forms ? I studied them a little before since easier to grasp.
They are used a lot in gamers code.
They should perform better.
It's also possible to have other degree curves with different matrix.
For example a 3 X 3 Patch with degree 2 Power basis.
Although the @last Bezier code base the degree on n_points so that should be the same.. ?
(this is for a curve)
# โ โ โ โ
# โ โ1 3 โ3 1 โ โ P1 โ MATRIX FORM for Cubic Bezier with 4 controlpoints.
# P(t) = [tยณ tยฒ t 1] ยท โ 3 โ6 3 0 โ . โ P2 โ
# โ โ3 3 0 0 โ โ P3 โ
# โ 1 0 0 0 โ โ P3 โ
# โ โ โ โ
#
# t = interval-value between 0 and 1. t2 = t*t, t3 = t2*t
# For even greater efficiency a,b,c,t3 coefficients could be cached and reused,
# and updated when interval/subd changes.
#
def power_basis(t3,t2,t, p0, p1, p2, p3)
# Calculate 4 coefficients (MATRIX T*U) where 4th coefficient is simply reusing t3
a = t3*(-1) + t2*3 + t*(-3) + 1
b = t3*3 + t2*(-6) + t*3
c = t3*(-3) + t2*3
# Calculate Points coordinates (MATRIX U*V)
x = a*p0.x + b*p1.x + c*p2.x + t3*p3.x
y = a*p0.y + b*p1.y + c*p2.y + t3*p3.y
z = a*p0.z + b*p1.z + c*p2.z + t3*p3.z
return Geom;;Point3d.new(x,y,z) # Return 1 point from interpolation
end