initial commit

This commit is contained in:
2023-05-24 00:27:34 +03:00
commit 11ee2c7949
174 changed files with 13452 additions and 0 deletions

View File

@ -0,0 +1,54 @@
import bpy
import mathutils
def draw_plane(hessian):
# Extract the plane coefficients from the Hessian form
a, b, c, d = hessian
# Calculate the normal vector of the plane
normal = mathutils.Vector((a, b, c))
# Calculate the point at the center of the plane
point = normal * d
# Calculate a vector perpendicular to the normal
if abs(normal.z) < 1e-6:
tangent = mathutils.Vector((0, 0, 1))
else:
tangent = mathutils.Vector((0, 1, -normal.y/normal.z)).normalized()
binorm = tangent.cross(normal)
# Create a new mesh object for the point, dot, and line
mesh = bpy.data.meshes.new(name="Plane Center and Normal")
obj = bpy.data.objects.new(name="Plane Object", object_data=mesh)
# Create the vertices for the point, dot, and line
vertices = [
point + tangent * 0.1,
point,
point + normal,
point + binorm * 0.1,
]
# Create the edges for the line
edges = [
(0, 1), # Edge from point to start of line
(1, 2) , # Edge for the line
(1, 3)
]
# Create the mesh data for the point, dot, and line
mesh.from_pydata(vertices, edges, [])
# Add the object to the scene
bpy.context.scene.collection.objects.link(obj)
planes = [(-0.96225, 0.192449, 0.192451, -4.04145), (-0.404079, 0.888975, 0.21551, -3.85222), (-0.703526, -0.502519, -0.502519, -2.31159), (-0.123091, -0.86164, 0.492366, -2.33874), (-0.211079, -0.492518, 0.844317, -3.02547), (0.442326, 0.147442, 0.884652, -2.50651), (0.928279, -0.206284, 0.309426, -1.13456), (0.973329, -0.162221, 0.162222, -1.29777), (0.117041, 0.702247, -0.702247, -3.04307), (-9.6656e-08, 1.35319e-07, -1, -2)]
#planes = [(0, 0, -1, -12), (0, 1, 0, 9)]
for p in planes:
draw_plane(p)
#draw_plane((0, 1, 0, 11))

View File

@ -0,0 +1,34 @@
import bpy
import mathutils
def create_plane_on_plane(p0):
# Extract the normal and distance from the Hessian form of the plane
normal = mathutils.Vector(p0[:3])
distance = p0[3]
# Calculate the center of the plane
center = normal * distance
# Create a new plane object
bpy.ops.mesh.primitive_plane_add()
obj0 = bpy.context.active_object
# Set the plane's origin to the center of the plane
obj0.location = center
# Calculate the rotation needed to align the z-axis with the plane normal
z_axis = mathutils.Vector((0, 0, 1))
angle = normal.angle(z_axis, 0)
axis = z_axis.cross(normal)
euler = mathutils.Matrix.Rotation(angle, 4, axis).to_euler()
obj0.rotation_euler = euler
return obj0
planes = [(0.274721, 9.82474e-08, -0.961524, -8.10427), (-1, -3.57626e-07, -2.38418e-07, -2), (0.904534, 0.301512, 0.301512, -1.50755), (0, 1, 0, 3), (5.08628e-06, -1, -2.75509e-06, -7.00003), (0.727606, -0.485071, -0.485072, -8.48875), (0.465341, -0.426562, -0.775566, -9.03536), (-0.369799, -0.0924517, 0.924501, 1.75654), (3.19872e-07, -0.447214, 0.894427, -0.447216), (-0.957704, -0.239427, 0.159618, -2.15484)]
for p in planes:
create_plane_on_plane(p)
#create_plane_on_plane((0.274721, 9.82474e-08, -0.961524, -8.10427))

View File

@ -0,0 +1,35 @@
import bpy
import mathutils
def draw_plane(hessian):
# Extract the plane coefficients from the Hessian form
a, b, c, d = hessian
# Calculate the normal vector of the plane
normal = mathutils.Vector((a, b, c)).normalized()
# Calculate the point at the center of the plane
point = normal * d
# Create a new mesh object for the point and line
mesh = bpy.data.meshes.new(name="Plane Center and Normal")
obj = bpy.data.objects.new(name="Plane Object", object_data=mesh)
# Create the vertices for the point and line
vertices = [
point,
point + normal
]
# Create the edges for the line
edges = [
(0, 1)
]
# Create the mesh data for the point and line
mesh.from_pydata(vertices, edges, [])
# Add the object to the scene
bpy.context.scene.collection.objects.link(obj)
draw_plane((0, 1, 0, 11))

View File

@ -0,0 +1,19 @@
import bpy
import bmesh
# Define the list of points for the polygon
points = [(0,0,0), (1,0,0), (1,1,0), (0,1,0)]
# Create a new mesh and add a new object to the scene
mesh = bpy.data.meshes.new("Polygon")
obj = bpy.data.objects.new("Polygon", mesh)
bpy.context.collection.objects.link(obj)
# Create a new bmesh and add vertices to it
bm = bmesh.new()
for point in points:
bm.verts.new(point)
# Add the vertices to the mesh
bm.to_mesh(mesh)
bm.free()

View File

@ -0,0 +1,36 @@
import bpy
import bmesh
# Define the list of faces, where each sublist represents a face
#faces = [
# [(0,0,0), (1,0,0), (1,1,0), (0,1,0)],
# [(1,0,0), (2,0,0), (2,1,0), (1,1,0)]
#]
faces = [
[(-2.999999, 6, -0.999997), (-2.999999, 9.999996, -0.999997), (-2.999999, 9.999996, 2.999999), (-2.999999, 6, 2.999999)],
[(-2.999999, 9.999996, -0.999997), (-2.999999, 6, -0.999997), (0.999997, 6, -0.999997), (0.999997, 9.999996, -0.999997)],
[(-2.999999, 6, -0.999997), (-2.999999, 6, 2.999999), (-0.999997, 6, 5), (2.999998, 6, 1.000004), (0.999997, 6, -0.999997)],
[(-2.999999, 9.999996, -0.999997), (0.999997, 9.999996, -0.999997), (1.999999, 9.999996, 0.000005), (-1.999997, 9.999996, 4), (-2.999999, 9.999996, 2.999999)],
[(-0.999997, 6, 5), (-2.999999, 6, 2.999999), (-2.999999, 9.999996, 2.999999), (-1.999997, 9.999996, 4), (-0.999997, 7.999996, 5)],
[(0.999997, 9.999996, -0.999997), (0.999997, 6, -0.999997), (2.999999, 6, 1.000004), (2.999999, 7.999996, 1.000004), (1.999998, 9.999996, 0.000004)],
[(-1.999997, 9.999996, 4), (1.999999, 9.999996, 0.000005), (2.999998, 7.999997, 1.000004), (-0.999997, 7.999997, 5)]
]
# Create a new mesh and add a new object to the scene
mesh = bpy.data.meshes.new("Polygon")
obj = bpy.data.objects.new("Polygon", mesh)
bpy.context.collection.objects.link(obj)
# Create a new bmesh and add vertices and faces to it
bm = bmesh.new()
for face_verts in faces:
# Add vertices for the face
verts = [bm.verts.new(v) for v in face_verts]
# Add a new face between the vertices
bm.faces.new(verts)
# Update the mesh and free the bmesh
bm.to_mesh(mesh)
bm.free()