CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Angle two vectors. (https://www.cfd-online.com/Forums/main/7540-angle-two-vectors.html)

Guest May 12, 2004 13:54

Angle two vectors.
 
Good morning,

I am looking to calculate the angle between two 3D vectors in my CFD results. I can do this mathematically, but I don't know how to implement it in code for a general coordinate system. Has anyone any ideas were I can learn how to use standard CFD code to calculate such quantities??

Rami May 13, 2004 02:28

Re: Angle two vectors.
 
<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head> <meta http-equiv=Content-Type content="text/html; charset=windows-1255"> <meta name=ProgId content=Word.Document> <meta name=Generator content="Microsoft Word 10"> <meta name=Originator content="Microsoft Word 10"> <link rel=File-List href="dot_files/filelist.xml"> <title>This actually is just basic vector analysis</title> <!--[if gte mso 9]><xml> <w:WordDocument> <w:SpellingState>Clean</w:SpellingState> <w:GrammarState>Clean</w:GrammarState> <w:Compatibility>

<w:BreakWrappedTables/>

<w:SnapToGridInCell/>

<w:WrapTextWithPunct/>

<w:UseAsianBreakRules/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--> <style>

</style> <!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable

{mso-style-name:"Table Normal";

mso-tstyle-rowband-size:0;

mso-tstyle-colband-size:0;

mso-style-noshow:yes;

mso-style-parent:"";

mso-padding-alt:0in 5.4pt 0in 5.4pt;

mso-para-margin:0in;

mso-para-margin-bottom:.0001pt;

mso-pagination:widow-orphan;

font-size:10.0pt;

font-family:"Times New Roman";} </style> <![endif]--> </head>

<body lang=EN-US style='tab-interval:.5in'>

<div class=Section1>

<p class=MsoNormal>This actually is just basic vector analysis. The scalar product of two vectors, a and b <span class=GramE>is<span style='mso-spacerun:yes'>* </span>a</span> · b = |a| |b| <span class=SpellE>cos<span style='font-family:Symbol'>f , </span>from</span> which <span style='font-family:Symbol'>f</span> – the angle between a and b – may be solved.


<p class=MsoNormal><o:p>*</o:p>


<p class=MsoNormal><o:p>*</o:p>


</div>

</body>

</html>

Guest May 13, 2004 09:33

Re: Angle two vectors.
 
I know that, but how do I implement it numerically. How do I implement it numerically? How do I calculate that angle using code?

Rami May 13, 2004 10:15

Re: Angle two vectors.
 
Fortran implementation:

real a(3), b(3)

AdotA = a(1)*a(1) + a(2)*a(2) + a(3)*a(3)

BdotB = b(1)*b(1) + b(2)*b(2) + b(3)*b(3)

den = AdotA*BdotB

if(den .gt. 0.) then

AdotB = a(1)*b(1) + a(2)*b(2) + a(3)*b(3)

cosphi = AdotB / sqrt(den)

phi = acos(cosphi)

endif


Guest May 16, 2004 07:48

Re: Angle two vectors.
 
Thank you.

If I have two grid lines, which are not orthogonal, how can I find the angle between them? What term do I use to describe their direction? Also, how is this done in a general curvilinear coordinate system? How can I find the angle between a grid line and a velocity field for example.

zxaar May 19, 2004 13:58

Re: Angle two vectors.
 
give me ur email i will drop u an email how to calculate what u need. (i understood that u want to use that in calculation for CFD, say for angle between the faces etc.)


Guest May 20, 2004 05:06

Re: Angle two vectors.
 
Hi zxaar,

This is my email account address as requested: cfd_user_uk@yahoo.co.uk

I would appreciate any help you can give me for this problem.

Thank you.

"give me ur email i will drop u an email how to calculate what u need. (i understood that u want to use that in calculation for CFD, say for angle between the faces etc.) "


All times are GMT -4. The time now is 10:05.