diff --git a/dot/README.md b/dot/README.md new file mode 100644 index 0000000..c8e53cc --- /dev/null +++ b/dot/README.md @@ -0,0 +1,2 @@ +not sure what this is, I think I was trying to figure out what a dot product +is diff --git a/dot/dot.pde b/dot/dot.pde new file mode 100644 index 0000000..a807e31 --- /dev/null +++ b/dot/dot.pde @@ -0,0 +1,39 @@ +PVector p1; +PVector p2; +PVector origin; + +void setup() { + size(500, 500); + background(255); + origin = new PVector(width * 0.5, height * 0.5); + p1 = new PVector(0, height * -0.25); + p2 = new PVector(width * 0.25, 0); +} + +void draw() { + background(255); + + translate(origin.x, origin.y); + + strokeWeight(4); + stroke(255, 0, 0); + line(0, 0, p1.x, p1.y); + + stroke(0, 255, 0); + line(0, 0, p2.x, p2.y); + + float p3 = PVector.dot(p1, p2); + fill(0); + textAlign(CENTER); + text(p3, 0, height * 0.25); +} + +void mouseClicked() { + p2.x = mouseX - origin.x; + p2.y = mouseY - origin.y; +} + +void mouseDragged() { + p2.x = mouseX - origin.x; + p2.y = mouseY - origin.y; +} \ No newline at end of file