Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Dear All,

Please help me to write a code in C# for adding 2 vectors which has magnitude and direction and stores the resultant vector magnitude and direction.


Thanks & Regards,
Lakshmaiah S

What I have tried:

Dear All,

Please help me to write a code in C# for adding 2 vectors which has magnitude and direction and stores the resultant vector magnitude and direction.


Thanks & Regards,
Lakshmaiah S
Posted
Updated 5-Oct-19 21:56pm
Comments
Richard MacCutchan 5-Oct-19 17:12pm    
You need to show what you have done and where you are stuck. This site is not here to do your work for you.
Patrice T 5-Oct-19 18:03pm    
You just have to apply the math formulas.

1 solution

To add two vectors, whatever their size (they only need to have the same number of components), you just add their components pairwise, which gives you the new vector.
You do not have to store the magnitude and direction, as they are immediately computable from the resulting vector.

First thing to do would be to know how to add two vectors and compute their magnitude and direction by hand (i.e., without any computer); then you can start thinking about developping some code around it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900