# How to Change a Horizontal Vector to Move in a 45 degree angle

## Homework Statement

I am using vPython, and object moves in a +x direction with a vector of <1e7,0,0>m. I need to now change the vector so that it now moves in the same +x direction, but also moving in the northeast direction at an angle of 45 degrees.

## The Attempt at a Solution

I attempted <1e7,1e7,0>, and it looks similar to what I need, but I don't know if it is exact or correct.

Thanks for your help.

gneill
Mentor

## Homework Statement

I am using vPython, and object moves in a +x direction with a vector of <1e7,0,0>m. I need to now change the vector so that it now moves in the same +x direction, but also moving in the northeast direction at an angle of 45 degrees.

## The Attempt at a Solution

I attempted <1e7,1e7,0>, and it looks similar to what I need, but I don't know if it is exact or correct.

Thanks for your help.

That will depend upon what vPython thinks the < , , > item is. Is it a velocity vector, with the individual parameters specifying the speed in the x,y,z directions? If so, and you want to keep the speed the same but change the direction, you want to have

$$speed = \sqrt{vx^2 + vy^2 + vz^2}$$

If you're dealing with just the x and y directions (planar motion), then you can set your speed and direction as:

$$vx = speed \cdot cos(\theta)$$
$$vy = speed \cdot sin(\theta)$$

where $$\theta$$ is the desired direction angle, and use these values as the parameters.

Putting the same value for both the x and y parameters gave you a 45 degree angle, but probably increased the overall speed by a factor of $$\sqrt{2}$$

Ok, I get it, and I got it working. Thanks for your help.

Where do you get the formula:
vx = speed * sin (45)?

Thanks.

gneill
Mentor
Where do you get the formula:
vx = speed * sin (45)?

Thanks.

That's vx = speed * cos(45)

It's basic trigonometry for a right-angle triangle. Vectors in the x and y directions add like the sides of a right angle triangle to form the hypotenuse. The trigonometric functions, sine and cosine, encapsulate the relationships between the angle and the ratios of the lengths of the sides to the hypotenuse.

Ok, So the x-component is 1e7cos(45), where the y-component is 1e7sin(45), so the hypotenuse is the vector that makes up both of these components, which allows the object to move in the direction that is 45 degrees from the horizontal.

Is that a decent understanding? Thanks for your help.

gneill
Mentor
That's fine. You're good to go!