Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
32
Task/Vector-products/FreeBASIC/vector-products.freebasic
Normal file
32
Task/Vector-products/FreeBASIC/vector-products.freebasic
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
'Construct only required operators for this.
|
||||
Type V3
|
||||
As double x,y,z
|
||||
declare operator cast() as string
|
||||
End Type
|
||||
#define dot *
|
||||
#define cross ^
|
||||
#define Show(t1,t) ? #t1;tab(22);t
|
||||
|
||||
operator V3.cast() as string
|
||||
return "("+str(x)+","+str(y)+","+str(z)+")"
|
||||
end operator
|
||||
|
||||
Operator dot(v1 As v3,v2 As v3) As double
|
||||
Return v1.x*v2.x+v1.y*v2.y+v1.z*v2.z
|
||||
End Operator
|
||||
|
||||
Operator cross(v1 As v3,v2 As v3) As v3
|
||||
Return type<v3>(v1.y*v2.z-v2.y*v1.z,-(v1.x*v2.z-v2.x*v1.z),v1.x*v2.y-v2.x*v1.y)
|
||||
End Operator
|
||||
|
||||
dim as V3 a = (3, 4, 5), b = (4, 3, 5), c = (-5, -12, -13)
|
||||
|
||||
Show(a,a)
|
||||
Show(b,b)
|
||||
Show(c,c)
|
||||
?
|
||||
Show(a . b,a dot b)
|
||||
Show(a X b,a cross b)
|
||||
Show(a . b X c,a dot b cross c)
|
||||
Show(a X (b X c),a cross (b cross c))
|
||||
sleep
|
||||
Loading…
Add table
Add a link
Reference in a new issue