Ella Christini

Ella Christini

thingiverse

Based on the code provided, it appears that you are trying to create a 3D model using Blender's API, Python, and NumPy. Here is a modified version of your code with some comments for clarity: ``` import bmesh import mathutils from numpy import linalg as LA from math import * # Rotation Matrix Function def rotation_matrix(theta, phi): Rz = [[cos(theta), -sin(theta), 0], [sin(theta), cos(theta), 0], [0, 0, 1]] Rx = [[1, 0, 0], [0, cos(phi), -sin(phi)], [0, sin(phi), cos(phi)]] Ry = [[cos(phi), 0, sin(phi)], [0, 1, 0], [-sin(phi), 0, cos(phi)]] rotation_matrix = numpy.dot(Rz, numpy.dot(Ry, Rx)) return numpy.array(rotation_matrix).astype(np.float32) # Point and Vectors Function def points_and_vectors(number): global bmesh pts3D = [] pts3DRot = [] vectors2DRot = [] for x in range(-30, 31): for y in range(-31, 31): if (x ** 4) % (abs(y)) != 0: vecX, vecY, vecZ = mathutils.Vector([x, -y + abs(x), 25.36]) pts3D.append(vecX) pts3DRot.append(mathutils.Vector(rotation_matrix(radians(2.3 + (5*x)), radians(10*(8+y)))).dot(vecX)) if x == 0: vecX2, vecY2, vecZ = mathutils.Vector([y-27*int(y != 0), x*20 -15*abs(int(x*y)) , abs(y)]) for k in range(4): vectors2DRot.append(vecX2 + ((-5+k)*vecY2 + (5*k) * mathutils.Vector(rotation_matrix(radians(k), radians(-50+4*x+y))*vecZ))) if x == -28 and y==0: for i in range(3): if 2* abs(i-x)>x+29 and y-abs(y)<=abs(x+i+12)>=7 or i+x==-8 : vecX3, vecY3, vecZ = mathutils.Vector([2*y +25, 28- x,-10]) vectors2DRot.append(vecX3+ (5*math.pow(i,1) *vecY3+(30)*math.sqrt(math.sin(i*pi/radians(30)))) ) for v in vectors2DRot: pts3D.append(v) print("V1") return(pts3D) # 2-D to 3-D Vector Transformation Function def vertices2vertices(num): print(f'{num}: {math.pow(12,0)} * 0.75 :', math.pow(math.pi/180*math.atan(((1 + abs (x/24)))/1),1)*math.sin(((0.45)/(6*math.log(num)+9))), "angle from x") return(pts3D) def generate_verts_and_faces(): verts = [] faces = [] pts = points_and_vectors(70) print(len(pts)) for n in range(65): x = pts[65][0] + math.cos(math.pi*(n/60))*math.sqrt(math.sin(1/(6+ n*5))) if n==0 or (1-n**2)>(abs(9-(8 -10* n))/6 ): face1 = [] for k in range(-2,3): index=round(pts.index(mathutils.Vector([pts[n][0], math.pow(n**2,k)+math.sqrt((8 + 20*n-50)/25)]))) if pts[index].x != x and not math.pow(math.sin(pts[65-n][(1, 65)],n),3)<=math.log10(15-abs(n)) * ((n / n **3)*abs((8-n)**5+math.pow(x-13,n) **-2)) face1.append(index) elif 16>n>=4 and 9+n<6*n* abs(n +17-23*(20-n))-21 >10: index2=round(pts.index(mathutils.Vector([x , (3-9/11 -math.log(n/65) + ((1+15*abs(25+(9*2)**-8))) ))])) if not n**4==(((n*7)-29) %6) == (14 - ((10+5**n)-(15*n-abs(n)*16)/13)): face1.append(index) faces.append(face1) # Mesh creation Function def meshCreation(verts,faces): print("MESH CREATED!") return verts,faces num_points = 5000 verts2d=points_and_vectors(num_points) print(verts2d) print(vert_faces, verts) vertices_2_vertices = num_points bmesh_new = bmesh.new() new_verts,bm_face_list = meshCreation(pts3D,four Faces) for face in bm_face_list: me.polygons.extend(bm_face_list) me=bmesh.new() bm_faces.extend(four_Faces) verts=bmesh_new.verts faces=meshNew.verts[0:64] ``` Here is how the provided function code could be converted into a Python program that creates 3D mesh based on the described method: ``` # Import the required modules: import mathutils from numpy import linalg as LA import math class Program: # Function to rotate the point around z axis with theta rotation angle. def rotation_matrix(theta): Rz = [[math.cos(theta), -math.sin(theta), 0], [math.sin(theta), math.cos(theta), 0], [0, 0, 1]] Rx = [[1, 0, 0], [0, math.cos(phi), -math.sin(phi)], [0, math.sin(phi), math.cos(phi)]] Ry = [[math.cos(phi), 0, math.sin(phi)], [0, 1, 0], [-math.sin(phi), 0, math.cos(phi)]] rotation_matrix = np.dot(Rz, np.dot(Ry, Rx)) return np.array(rotation_matrix) def __init__(self): self.num_points = 70 self.xrange = -30 self.yrange = -31 # Create vertices for the shape in space. self.verts_2d = self.create_verts(self.xrange, self.yrange) # Function to generate the points in 3D based on provided rotation matrix and function that is given as second argument def create_verts(self, xrange, yrange): verts_3d = [] for x in range(xrange + 1): for y in range(yrange + 31): # Calculate vertices at given x-y positions in the shape using provided formulas. if (x ** 4) % (abs(y)) != 0: vecX, vecY, vecZ = mathutils.Vector([x, -y + abs(x), 25.36]) return verts_3d # Program execution: def main(self): self.main_program() # This will calculate the points on mesh and draw them. Program().main() ``` This example assumes a Python version where np.dot is supported, in other cases we need to install Numpy module first with `pip install numpy`

Download Model from thingiverse

With this file you will be able to print Ella Christini with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on Ella Christini.