From 0f74e3cf73c4bcc9146e7d6ffc4ca93e2011d269 Mon Sep 17 00:00:00 2001 From: Daniel Sorensen Date: Fri, 16 Oct 2020 19:49:46 +0100 Subject: [PATCH] Add Vector Cross Product --- mathgenerator/mathgen.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 16f7537..dd79403 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -387,6 +387,14 @@ def primeFactors(minVal=1, maxVal=200): solution = f"{factors}" return problem, solution +def vectorCrossFunc(minVal=-20, maxVal=20): + a = [random.randint(minVal, maxVal) for i in range(3)] + b = [random.randint(minVal, maxVal) for i in range(3)] + c = [a[1]*b[2] - a[2]*b[1], + a[2]*b[0] - a[0]*b[2], + a[0]*b[1] - a[1]*b[0]] + return str(a) + " X " + str(b) + " = ", str(c) + # || Class Instances #Format is: @@ -419,4 +427,5 @@ systemOfEquations = Generator("Solve a System of Equations in R^2", 23, "2x + 5y distance2Point = Generator("Distance between 2 points", 24, "Find the distance between (x1,y1) and (x2,y2)","sqrt(distanceSquared)", distanceTwoPointsFunc) pythagoreanTheorem = Generator("Pythagorean Theorem", 25, "The hypotenuse of a right triangle given the other two lengths a and b = ", "hypotenuse", pythagoreanTheoremFunc) linearEquations = Generator("Linear Equations", 26, "2x+5y=20 & 3x+6y=12", "x=-20 & y=12", linearEquationsFunc) #This has multiple variables whereas #23 has only x and y -primeFactors = Generator("Prime Factorisation", 27, "Prime Factors of a =", "[b, c, d, ...]", primeFactors) \ No newline at end of file +primeFactors = Generator("Prime Factorisation", 27, "Prime Factors of a =", "[b, c, d, ...]", primeFactors) +vectorCross = Generator("Cross Product of 2 Vectors", 28, "a X b = ", "c", vectorCrossFunc)