Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Vector library #34

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

RFC: Vector library #34

wants to merge 16 commits into from

Conversation

ffrostfall
Copy link

@ffrostfall ffrostfall marked this pull request as draft May 13, 2024 23:14
@ffrostfall ffrostfall marked this pull request as ready for review May 14, 2024 14:11
@kalrnlo
Copy link

kalrnlo commented May 31, 2024

I think the min, max functions should accept multiple vectors as the current math.max and min allow multiple numbers, plus roblox's vector3s min and max methods also accept multiple vectors.

There should also be abs and clamp functions, as those would be useful for vectors. Plus id assume it would be intended to keep the vector library in feature parity somewhat with the math lib.


---

`vector(x: number?, y: number?, z: number?)`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
`vector(x: number?, y: number?, z: number?)`
`vector(x: number, y: number, z: number)`

It's best to encourage practice of hitting the fastest constructor we have available.

It will also avoid confusion of what vector(1) is.
While Vector3.new(1) is [1, 0, 0] on Roblox, for people coming from GLSL where vec3(1) is [1, 1, 1], it might be unintuitive.
Even if supported by runtime, the typing can be more strictly defined.


`vector.angle(vecA: vector, vecB: vector): vector`

Returns the angle between two vectors.
Copy link
Contributor

Choose a reason for hiding this comment

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

In what units?


Returns the cross product of two vectors. If 4-wide vectors are enabled, this function will ignore the fourth component, and return the 3-dimensional cross product.

`vector.dot(vecA: vector, vecB: vector): vector`
Copy link
Contributor

Choose a reason for hiding this comment

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

dot product results in a number.

@bradsharp
Copy link

Would we include this in the Roblox engine?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants