fix bad normal calculation

master
pullusb 2024-07-18 18:22:40 +02:00
parent b65a60126d
commit fca531bf35
2 changed files with 25 additions and 7 deletions

View File

@ -1,7 +1,7 @@
bl_info = { bl_info = {
"name": "gp interpolate", "name": "gp interpolate",
"author": "Christophe Seux, Samuel Bernou", "author": "Christophe Seux, Samuel Bernou",
"version": (0, 7, 3), "version": (0, 7, 4),
"blender": (3, 6, 0), "blender": (3, 6, 0),
"location": "Sidebar > Gpencil Tab > Interpolate", "location": "Sidebar > Gpencil Tab > Interpolate",
"description": "Interpolate Grease pencil strokes over 3D", "description": "Interpolate Grease pencil strokes over 3D",

View File

@ -35,12 +35,30 @@ class attr_set():
# --- Vector # --- Vector
def triangle_normal(a, b, c): def triangle_normal(p1, p2, p3):
x = a[1] * b[2] - a[2] * b[1] """
y = a[2] * b[0] - a[0] * b[2] Calculate the normal of a triangle given its three vertices.
z = a[0] * b[1] - a[1] * b[0]
Parameters:
return np.array([x, y, z], dtype='float64') p1, p2, p3: the 3 vertices of the triangle
Returns:
mathutils.Vector: The normalized normal vector of the triangle.
"""
## Get edge vectors
edge1 = Vector(p2) - Vector(p1)
edge2 = Vector(p3) - Vector(p1)
## Get normal (Cross product of the edge vectors)
normal = edge1.cross(edge2)
normal.normalize()
return normal
## Bad normal calculation !!
# def triangle_normal(a, b, c):
# x = a[1] * b[2] - a[2] * b[1]
# y = a[2] * b[0] - a[0] * b[2]
# z = a[0] * b[1] - a[1] * b[0]
# return np.array([x, y, z], dtype='float64')
def plane_coords(size=1): def plane_coords(size=1):
v = size * 0.5 v = size * 0.5