Data update
This commit is contained in:
parent
29a5eea0d4
commit
5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions
26
Task/Vector-products/PascalABC.NET/vector-products.pas
Normal file
26
Task/Vector-products/PascalABC.NET/vector-products.pas
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
uses System.Numerics;
|
||||
|
||||
function DotProduct(v1,v2: Vector3): real
|
||||
:= v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
|
||||
|
||||
function CrossProduct(v1,v2: Vector3): Vector3
|
||||
:= new Vector3(v1.y * v2.z - v1.z * v2.y,
|
||||
v1.z * v2.x - v1.x * v2.z,
|
||||
v1.x * v2.y - v1.y * v2.x);
|
||||
|
||||
function ScalarTripleProduct(a,b,c: Vector3): real
|
||||
:= DotProduct(a, CrossProduct(b, c));
|
||||
|
||||
function VectorTripleProduct(a,b,c: Vector3): Vector3
|
||||
:= CrossProduct(a, CrossProduct(b, c));
|
||||
|
||||
|
||||
begin
|
||||
var a := new Vector3(3,4,5);
|
||||
var b := new Vector3(4,3,5);
|
||||
var c := new Vector3(-5,-12,-13);
|
||||
Writeln(DotProduct(a, b));
|
||||
Writeln(CrossProduct(a, b));
|
||||
Writeln(ScalarTripleProduct(a, b, c));
|
||||
Writeln(VectorTripleProduct(a, b, c));
|
||||
end.
|
||||
|
|
@ -1,19 +1,26 @@
|
|||
/*REXX program computes the products: dot, cross, scalar triple, and vector triple.*/
|
||||
a= 3 4 5
|
||||
b= 4 3 5 /*(positive numbers don't need quotes.)*/
|
||||
c= "-5 -12 -13"
|
||||
call tellV 'vector A =', a /*show the A vector, aligned numbers.*/
|
||||
call tellV 'vector B =', b /* " " B " " " */
|
||||
call tellV 'vector C =', c /* " " C " " " */
|
||||
say
|
||||
call tellV ' dot product [A∙B] =', dot(a, b)
|
||||
call tellV 'cross product [AxB] =', cross(a, b)
|
||||
call tellV 'scalar triple product [A∙(BxC)] =', dot(a, cross(b, c) )
|
||||
call tellV 'vector triple product [Ax(BxC)] =', cross(a, cross(b, c) )
|
||||
exit 0 /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
cross: procedure; arg $1 $2 $3,@1 @2 @3; return $2*@3 -$3*@2 $3*@1 -$1*@3 $1*@2 -$2*@1
|
||||
dot: procedure; arg $1 $2 $3,@1 @2 @3; return $1*@1 + $2*@2 + $3*@3
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
tellV: procedure; parse arg name,x y z; w=max(4,length(x),length(y),length(z)) /*max W*/
|
||||
say right(name,40) right(x,w) right(y,w) right(z,w); /*show vector.*/ return
|
||||
/*REXX program computes the products: dot, cross, scalar triple, and vector triple.*/
|
||||
a= 3 4 5
|
||||
b= 4 3 5 /*(positive numbers don't need quotes.)*/
|
||||
c= '-5 -12 -13'
|
||||
Call tellV 'vector A =', a /*show the A vector, aligned numbers.*/
|
||||
Call tellV "vector B =", b /* " " B " " " */
|
||||
Call tellV "vector C =", c /* " " C " " " */
|
||||
Say ''
|
||||
Call tellV ' dot product [A·B] =', dot(a,b)
|
||||
Call tellV 'cross product [AxB] =', cross(a,b)
|
||||
Call tellV 'scalar triple product [A·(BxC)] =', dot(a,cross(b,c))
|
||||
Call tellV 'vector triple product [Ax(BxC)] =', cross(a,cross(b,c))
|
||||
Exit /*stick a fork in it, we're all done. */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
cross: Procedure
|
||||
Arg a b c, u v w
|
||||
Return b*w-c*v c*u-a*w a*v-b*u
|
||||
dot: Procedure
|
||||
Arg a b c, u v w
|
||||
Return a*u + b*v + c*w
|
||||
/*---------------------------------------------------------------------------*/
|
||||
tellV: Procedure
|
||||
Parse Arg name,x y z
|
||||
w=max(4,length(x),length(y),length(z)) /*max width */
|
||||
Say right(name,33) right(x,w) right(y,w) right(z,w) /*show vector. */
|
||||
Return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue