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]
file1 = open('C:\\Users\\yuno gasai\\Downloads\\A3-2 (1)\\A3-2\\coons_patch_points.txt', 'r')
Lines = file1.readlines()
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.add(1)
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
scn.collection.objects.link(curveOB)
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