gwg/vec
2
3
Fork
You've already forked vec
4

feat: add axis normal vector constants to float and int modules #5

Merged
NNB merged 1 commit from seancribbs/vec:seancribbs/axis-normal-vectors into main 2026年04月05日 21:12:57 +02:00
Contributor
Copy link

More constants are good!

More constants are good!

Looks good!

Looks good!
Owner
Copy link

Good idea but the naming is confused with these functions, maybe the name should be x_positive, y_positive ext... would be better, and follow with that ?_negative would be useful too. As this would be similar to Godot's LEFT, RIGHT, UP, DOWN consts without enforcing which axis/sign to which direction.

Good idea but the naming is confused with [these functions](https://hexdocs.pm/vec/vec/vec2.html#x), maybe the name should be `x_positive`, `y_positive` ext... would be better, and follow with that `?_negative` would be useful too. As this would be similar to [Godot's `LEFT`, `RIGHT`, `UP`, `DOWN` consts](https://docs.godotengine.org/en/stable/classes/class_vector2.html#class-vector2-constant-left) without enforcing which axis/sign to which direction.

I would personally get rid of the x and y functions as the vec type is not opaque and you can do vec.x and vec.y. I don’t see the verbosity in positive_x and positive _y

I would personally get rid of the x and y functions as the vec type is not opaque and you can do vec.x and vec.y. I don’t see the verbosity in positive_x and positive _y
Author
Contributor
Copy link

Happy to add neg_x, etc, and rename as needed. What's the consensus?

Happy to add `neg_x`, etc, and rename as needed. What's the consensus?
Owner
Copy link

Yep positive_* and negative_* is the way ;)

Yep `positive_*` and `negative_*` is the way ;)
Owner
Copy link

@renatillas wrote in #5 (comment):

I would personally get rid of the x and y functions as the vec type is not opaque and you can do vec.x and vec.y.

Yeah I know, I usually don't make that kind of functions, but the stdlib do have first and second functions for pair while user can just do pair.0, pair.1. So I think that: type that are generic and get use regular should have functions that extract element from it so it can be use in list.map(vec2.x) for example.

@renatillas wrote in https://codeberg.org/gwg/vec/pulls/5#issuecomment-10907495: > I would personally get rid of the x and y functions as the vec type is not opaque and you can do vec.x and vec.y. Yeah I know, I usually don't make that kind of functions, but the stdlib do have [`first`](https://hexdocs.pm/gleam_stdlib/gleam/pair.html#first) and [`second`](https://hexdocs.pm/gleam_stdlib/gleam/pair.html#second) functions for pair while user can just do `pair.0`, `pair.1`. So I think that: type that are generic and get use regular should have functions that extract element from it so it can be use in `list.map(vec2.x)` for example.
seancribbs force-pushed seancribbs/axis-normal-vectors from 23f66c361e to d0eb87c288 2026年04月05日 21:07:10 +02:00 Compare
Author
Contributor
Copy link

@NNB I've updated my diff with the changes you suggested, let me know what you think!

@NNB I've updated my diff with the changes you suggested, let me know what you think!
Owner
Copy link

This seem good, Ima merge this now and retouch up some stuff and publish the change tomorrow, thank you!

This seem good, Ima merge this now and retouch up some stuff and publish the change tomorrow, thank you!
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
gwg/vec!5
Reference in a new issue
gwg/vec
No description provided.
Delete branch "seancribbs/vec:seancribbs/axis-normal-vectors"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?