Skip to content

Quaternion Class package#31

Open
Raild3x wants to merge 1 commit intomainfrom
feat/Quaternion
Open

Quaternion Class package#31
Raild3x wants to merge 1 commit intomainfrom
feat/Quaternion

Conversation

@Raild3x
Copy link
Owner

@Raild3x Raild3x commented Sep 24, 2025

This pull request introduces a new, well-documented quaternion implementation for 3D rotations in Roblox, along with an initial package manifest for Wally package management. The main focus is on providing a robust, type-annotated, and performant Quaternion class with comprehensive API documentation and example usage.

Quaternion Implementation and Documentation:

  • Added a new Quaternion class in init.luau with detailed type annotations, method documentation, and usage examples. The implementation includes quaternion creation, multiplication, exponentiation, conversion to/from CFrame, inversion, axis-angle conversion, and both standard and shortest-path spherical linear interpolation (SLERP). Performance notes and recommendations for further optimization are included throughout the code.

Package Management:

  • Added a wally.toml manifest describing the package metadata, authorship, licensing, and registry information for Wally package management, enabling easier distribution and dependency management.

@Raild3x Raild3x self-assigned this Sep 24, 2025
Copilot AI review requested due to automatic review settings September 24, 2025 18:54
@Raild3x Raild3x added enhancement New feature or request Not Ready labels Sep 24, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new quaternion implementation for 3D rotations in Roblox, providing a robust alternative to Euler angles and rotation matrices. The implementation focuses on type safety, performance considerations, and comprehensive documentation.

Key changes:

  • Added a complete Quaternion class with mathematical operations (multiplication, exponentiation, SLERP)
  • Implemented conversion methods between CFrame and quaternion representations
  • Created Wally package configuration for distribution and dependency management

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lib/quaternion/wally.toml Package manifest with metadata, licensing, and registry configuration
lib/quaternion/src/init.luau Complete quaternion implementation with type annotations, mathematical operations, and comprehensive documentation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +15 to +17
# Whether or not to ignore this package in the readme


Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment on line 15 is incomplete - it mentions ignoring the package in readme but doesn't specify the actual configuration key or value that would control this behavior.

Suggested change
# Whether or not to ignore this package in the readme
# Whether or not to ignore this package in the readme. Set to true to ignore, false to include.
ignoreInReadme = false

Copilot uses AI. Check for mistakes.
local theta = acos(self.W) * 2

-- if theta is equivalent to zero then pick a random axis
if theta % (PI * 2) == 0 and axis:Dot(axis) == 0 then
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using modulo with floating-point numbers can be unreliable due to precision issues. Consider using a small epsilon tolerance instead: if math.abs(theta % (PI * 2)) < 1e-10 and axis:Dot(axis) < 1e-10 then

Suggested change
if theta % (PI * 2) == 0 and axis:Dot(axis) == 0 then
if math.abs(theta % (PI * 2)) < 1e-10 and axis:Dot(axis) == 0 then

Copilot uses AI. Check for mistakes.
```
]=]
function quaternion:SlerpClosest(self2: Quaternion, t: number): Quaternion
if self.W * self2.W + self.X * self2.X + self.Y * self2.Y + self.Z * self2.Z > 0 then
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dot product calculation is duplicated - it could be computed once and stored in a variable to avoid redundant multiplication operations.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Not Ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant