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

Add Vector2Dir function to get the direction vector of two given points #3754

Closed
wants to merge 1 commit into from

Conversation

Elkantor
Copy link
Contributor

@Elkantor Elkantor commented Jan 22, 2024

I always add this function anyway on my raylib projects, so I think that could be usefull to get this function directly in raymath.
But it's really not mandatory.
Note: the function name is quite "quick and dirty", but hey, it is probably enough?

@Peter0x44
Copy link
Contributor

Isn't this just Vector2Subtract with the arguments flipped? What's the need for this?

@Elkantor
Copy link
Contributor Author

Isn't this just Vector2Subtract with the arguments flipped? What's the need for this?

Yes, totally! Indeed, but actually it's just the name which matters. Anyway, I didn't even took attention to Vector2Substract! Gosh I'm tired haha

@Peter0x44
Copy link
Contributor

Peter0x44 commented Jan 22, 2024

I think that name is super confusing and ambiguous. Vector2Subtract is not.

@Elkantor Elkantor closed this Jan 22, 2024
@Elkantor Elkantor deleted the patch-2 branch January 22, 2024 21:21
@idircarlos
Copy link
Contributor

I understand the intention of @Elkantor. Calculating the direction vector of a line (or a plane) is a common operation when working with vectors. Here is my opinion on this. In case we are adding the function, I would:

  • Rename it to Vector2Direction, which is a more self-explanatory.
  • Vector2 result = Vector2Subtract(v2, v1); instead of Vector2 result = { p2.x - p1.x, p2.y - p1.y };
  • Add the same function for a plane (defined by 3 points)

But this is just my opinion :) I hope it helps.

@raysan5
Copy link
Owner

raysan5 commented Jan 23, 2024

@Peter0x44 thanks for looking into this, I was aware of some similar function already available.

@Elkantor @idircarlos A Vector2Direction() could be useful but probably as a normalized vector, afaik a direction is more useful normalized, right? Not sure if there is any similar alternative.

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

Successfully merging this pull request may close these issues.

4 participants