Vector products: Difference between revisions

Content added Content deleted
(→‎{{header|Go}}: added output. (thx Paddy for checking my work!))
({{header|Liberty BASIC}})
Line 573: Line 573:
6.0
6.0
<-267.0, 204.0, -3.0></pre>
<-267.0, 204.0, -3.0></pre>

=={{header|Liberty BASIC}}==
<lang lb> print "Vector products of 3-D vectors"

print "Dot product of 3,4,5 and 4,3,5 is "
print DotProduct( "3,4,5", "4,3,5")
print "Cross product of 3,4,5 and 4,3,5 is "
print CrossProduct$( "3,4,5", "4,3,5")
print "Scalar triple product of 3,4,5, 4,3,5 -5, -12, -13 is "
print ScalarTripleProduct( "3,4,5", "4,3,5", "-5, -12, -13")
print "Vector triple product of 3,4,5, 4,3,5 -5, -12, -13 is "
print VectorTripleProduct$( "3,4,5", "4,3,5", "-5, -12, -13")


end

function DotProduct( i$, j$)
ix =val( word$( i$, 1, ","))
iy =val( word$( i$, 2, ","))
iz =val( word$( i$, 3, ","))
jx =val( word$( j$, 1, ","))
jy =val( word$( j$, 2, ","))
jz =val( word$( j$, 3, ","))
DotProduct = ix *jx +iy *jy + iz *jz
end function

function CrossProduct$( i$, j$)
ix =val( word$( i$, 1, ","))
iy =val( word$( i$, 2, ","))
iz =val( word$( i$, 3, ","))
jx =val( word$( j$, 1, ","))
jy =val( word$( j$, 2, ","))
jz =val( word$( j$, 3, ","))
cpx =iy *jz -iz *jy
cpy =iz *jx -ix *jz
cpz =ix *jy -iy *jx
CrossProduct$ =str$( cpx); ","; str$( cpy); ","; str$( cpz)
end function

function ScalarTripleProduct( i$, j$, k$))
ScalarTripleProduct =DotProduct( i$, CrossProduct$( j$, k$))
end function

function VectorTripleProduct$( i$, j$, k$))
VectorTripleProduct$ =CrossProduct$( i$, CrossProduct$( j$, k$))
end function
END SUB
</lang>


=={{header|Lua}}==
=={{header|Lua}}==