Skip to content

Utilize Vector Classes over Numpy Library #30

@KcRobin9

Description

@KcRobin9

The Editor currently uses the numpy library for vector operations in several geometric calculations, such as computing normals. While numpy is powerful, the custom Vector2 and Vector3 classes provide tailored methods that could enhance performance and reduce external dependencies.

For instance:

def compute_normal(vertex_1: Vector3, vertex_2: Vector3, vertex_3: Vector3) -> np.ndarray:
    v1 = np.array(vertex_2) - np.array(vertex_1)
    v2 = np.array(vertex_3) - np.array(vertex_1)
    normal = np.cross(v1, v2)
    return normal / np.linalg.norm(normal)

Could be refactored into:

def compute_normal(vertex_1: Vector3, vertex_2: Vector3, vertex_3: Vector3) -> Vector3:
    v1 = vertex_2 - vertex_1
    v2 = vertex_3 - vertex_1
    normal = v1.Cross(v2)
    return normal.Normalize()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions