Skip to content

Instantly share code, notes, and snippets.

@unrealwill
unrealwill / bezier.py
Created October 18, 2025 21:50
Finding distance point to bezier curve (illustration purpose)
import torch as th
def bezier( t, P1, P2, P3, P4 ):
return P1*(1-t**3) + P2*3*(1-t**2)*t + P3*3*(1-t)*t*t + P4*t**3
def dist2( a, b):
return th.sum( (a-b)**2 )
P = th.tensor((1,2))