Solving 3D Vectors Physics Programming Question

In summary, the conversation discusses a programming question involving a man's position and facing direction in relation to a sweet dish. The suggested solution involves using vectors and the dot product to determine if the man is facing the dish. The importance of the man's position is emphasized and the suggestion to make a sketch to better understand the problem is given.
  • #1
volta7
1
0

Homework Statement


A man is standing in his home , his position his facing direction and the position of the sweet dish are given ,if he faces the sweet dish , he eats it .
Translating it into CS programming question : write a function ->
bool IsManInFrontofDish( vector3& manPosition, vector3& manFacingPos, vector3& dishPos )
which return true when the man faces the dish;

The programming part is easy , I was worried about the physics part .
Is the manPosition really important in this , or is it just to deceive?
I am attempting a physics programming question for the first time...

Homework Equations


A.B = ||A||.||B||

The Attempt at a Solution


the angle between 2 vectors is 0 if they are in the same direction so simply by replacing manFacingPos with A and
dishPos with B and checking the equation i will be able to get the answer:
translating it into program if it helps :

bool IsManInFrontofDish( vector3& manPosition, vector3& manFacingPos, vector3& dishPos ) {
int magnitude1 = sqrt( dot(manFacingPos, manFacingPos) ); //square root of dot product
int magnitude2 = sqrt( dot(dishPos,dishPos) );
if(dot(manFacingPos, dishPos) == magnitude1*magnitude2) return true;
else return false;
}

P.S. I am not attending any university or school right now , so this is not a homework question
 
Physics news on Phys.org
  • #2
It would probably be easier to take the two positions (man and sweet dish) and form a unit vector pointing from the man to the dish. Then form a unit vector from the man's facing direction vector. Compare them.

That the man's position is important should be clear. Make a sketch. Keeping the same facing direction vector, move the man about the room and see if he ever faces the sweet dish depending upon his location.
 

FAQ: Solving 3D Vectors Physics Programming Question

What are 3D vectors in physics?

In physics, 3D vectors are mathematical quantities that have both magnitude and direction in three-dimensional space. They are commonly used to represent physical quantities such as velocity, force, and displacement.

How do you solve 3D vector problems in physics?

To solve 3D vector problems in physics, you can use vector operations such as addition, subtraction, and scalar multiplication. You can also use trigonometric functions and the Pythagorean theorem to find the magnitude and direction of a vector.

What is the connection between 3D vectors and programming?

3D vectors are commonly used in programming to represent objects in three-dimensional space. They are used in graphics and game development to determine the position, orientation, and movement of objects. They are also used in simulations and physics engines.

What are some common challenges when solving 3D vector problems in physics programming?

Some common challenges when solving 3D vector problems in physics programming include understanding vector operations, managing vector components, and visualizing vectors in three-dimensional space. It can also be challenging to accurately represent and calculate vectors in a computer program.

What are some tips for solving 3D vector problems in physics programming?

Some tips for solving 3D vector problems in physics programming include breaking down the problem into smaller parts, using diagrams or visual aids, and checking your calculations for accuracy. It can also be helpful to familiarize yourself with vector operations and their properties.

Similar threads

Replies
3
Views
1K
Replies
14
Views
4K
Replies
3
Views
2K
Replies
10
Views
2K
Replies
5
Views
2K
Replies
2
Views
1K
Back
Top