Sign in to follow this  
Phineas

Name for a Vector Function

Recommended Posts

I have the following function for a 2d vector struct that takes a magnitude and diretion and adds it to a vector:
void foo(Vector2d v, SCALAR magnitude, RADIANS angle)
{
  SCALAR x, y;

  x = magnitude * cos(angle);
  y = magnitude * sin(angle);

  v.x += x;
  v.y += y;
}


I'm not sure what to name this function. addVector isn't good because a magnitude and a direction is not really a vector. Any ideas? It often seems that coming up with intuitive names is the most difficult part about Software Engineering (used in the loosest sense, as applied to my novice game programming skills). Thanks for your help.

Share this post


Link to post
Share on other sites
Quote:
Original post by Phineas
addVector isn't good because a magnitude and a direction is not really a vector.

A magnitude and a direction is a vector.

In this case you're adding a vector represented in polar coordinates to a vector represented in cartesian coordinates.

addPolarVector seems like a decent name for it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this