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

Click For Summary
SUMMARY

The discussion focuses on modifying a velocity vector in vPython to achieve movement at a 45-degree angle while maintaining the same speed. The original vector is <1e7,0,0> m, and the correct approach involves using trigonometric functions to calculate the new components. Specifically, the x-component is determined by vx = speed * cos(45) and the y-component by vy = speed * sin(45). This ensures that the resultant vector maintains the desired speed while changing direction appropriately.

PREREQUISITES
  • Understanding of vPython and its vector representation
  • Basic knowledge of trigonometry, specifically sine and cosine functions
  • Familiarity with vector components in two-dimensional motion
  • Ability to calculate speed using the Pythagorean theorem
NEXT STEPS
  • Learn about vector manipulation in vPython
  • Study trigonometric functions and their applications in physics
  • Explore the concept of velocity vectors in two-dimensional motion
  • Investigate how to maintain constant speed while changing direction in simulations
USEFUL FOR

Students and developers working with vPython, physics enthusiasts, and anyone interested in understanding vector dynamics and trigonometric applications in programming.

Loppyfoot
Messages
192
Reaction score
0

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.
 
Physics news on Phys.org
Loppyfoot said:

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.
 
Loppyfoot said:
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.
 
That's fine. You're good to go!
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 21 ·
Replies
21
Views
1K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
15
Views
5K
  • · Replies 10 ·
Replies
10
Views
2K
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
3
Views
1K