# Coon's Patch: Bezier Curve

I have a text file that has four sets of points. In each set, the first and last points are the start and end points of a curve, and the middle two are the coordinates for two handle points. I have to generate Coon's patch. I only know that these four sets of control points define Coon's patch's boundary. Can anyone guide me further? I have to write a Python script for this, and I am not sure where or how to start. Can anyone explain or point to a resource where I can check out what Coon's patch is? I am new to blender

EDIT: I have drawn the bezier curves. I know the formula for coon's patch but i cannot find how to draw that with script in blender

import bpy
import numpy as np
from bpy import context, data, ops

def new_bezier_point (p0, p0hr, p1hl, p1, t):
t1 = p0 + (p0hr - p0) * t
t2 = p0hr + (p1hl - p0hr) * t
t3 = p1hr + (p1 - p1hl) * t
p2hl = t1 + (t2 - t1) * t
p2hr = t2 + (t3 - t2) * t
p2 = p2hl + (p2hr - p2hl) * t
return [t1, p2hl, p2, p2hr, t3]

Lines=np.array(Lines)
Lines=Lines.reshape((4,4))

for i in Lines:
c=i[0].split()
l=i[1].split()
r=i[2].split()
e=i[3].split()

coords = [np.array([float(c[0]),float(c[1]),float(c[2])]), np.array([float(l[0]),float(l[1]),float(l[2])]), np.array([float(r[0]),float(r[1]),float(r[2])]), np.array([float(e[0]),float(e[1]),float(e[2])])]

curveData = bpy.data.curves.new('myCurve', type='CURVE')
curveData.dimensions = '3D'
curveData.resolution_u = 20

polyline = curveData.splines.new('BEZIER')

polyline.bezier_points[0].co = coords[0]
polyline.bezier_points[0].handle_right=coords[1]
polyline.bezier_points[1].co = coords[2]
polyline.bezier_points[1].handle_left=coords[3]

curveOB = bpy.data.objects.new('myCurve', curveData)

scn = bpy.context.scene
bpy.context.view_layer.objects.active = curveOB
curveOB.select_set(True)

obj_data = curveOB.data

obj_data.fill_mode = 'FULL'

obj_data.extrude = 0.125

obj_data.bevel_depth = 0.125

obj_data.resolution_u = 20
obj_data.render_resolution_u = 20


And this is what i am trying to implement

• Wikipedia knows what it is... You need a 3D interpolation between the points. There must be a set of rules or sample code online. Commented Nov 11, 2022 at 9:43
• i cant find the right functions in blender scripting i know the structure of coon's patch but i am havibg trouble finding to draw a bezier curve with giving start point end point and two handle points. Commented Nov 15, 2022 at 9:51
• only one curve? Or the entire surface? 2 handle points each, or 1 for end, 1 for start? Commented Nov 15, 2022 at 18:32
• yes i need to draw 4 bezier curves through python script each curve has 2 handle points, 1 start point and 1 end point Commented Nov 15, 2022 at 22:16
• I cant seem to find how to draw a curve from start point to end point in python every method i saw for drawing bezier curve only used 1 point as location Commented Nov 15, 2022 at 22:17

EDIT: I posted this back when you were asking only about the curve editing script. I'll check your edit and see if I can update the answer.

import bpy
from mathutils import Vector

C = bpy.context
D = bpy.data

path = D.curves.new("path1", 'CURVE') # create empty curve data
spline = path.splines.new('BEZIER') # create a new spline