How to get 'Keyframe Bezier' points

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By QonDonion

basically points of this
–KEYBEZ–

from the positions and handles
please :3

:bust_in_silhouette: Reply From: QonDonion

i think the reason no one answers my questions is because the question takes too much time
or too hard for anyone to care
which i totally understand lol

the solution is:

func computeBezJr(P0, P1, P2, P3, t):
	var u = 1 - t
	return (u*u*u) * P0 + 3 * (u*u) * t * P1 + 3 * u * (t*t) * P2 + (t*t*t) * P3

func computeKeyBez(pointS, numPoints):
	var P0 = pointS[0]
	var P1 = pointS[1]
	var P2 = pointS[2]
	var P3 = pointS[3]
	
	var points = []

	var middle = computeBezJr(P0, P1, P2, P3, 0.5)
	
	for i in range(numPoints):
		var t = i / float(numPoints - 1)
		var point = computeBezJr(P0, P1, P2, P3, t)
		
		if (point.x > P0.x and point.x < P3.x):
			if t > 0.5:
				if point.x > middle.x:
					points.append(point)
			if t < 0.5:
				if point.x < middle.x:
					points.append(point)

	return points

yeah <:3

yeah i just
looked at the curve,
messed around with the points,
try to think of the solution
until i got this answer

QonDonion | 2023-07-06 13:25