Geometry
Lab setup
First, make sure you have completed the initial setup.
If you are part of a course
-
Open Terminal. Run the update command to make sure you have the latest code.
$ mwc update -
Move to this lab's directory.
$ cd ~/Desktop/making_with_code/mwc1/unit3/lab_geometry
If you are working on your own
-
Move to your MWC directory.
$ cd ~/Desktop/making_with_code -
Get a copy of this lab's materials.
git clone https://git.makingwithcode.org/mwc/lab_geometry.git
Work in progress. This lab isn't finished yet -- it's included here so it can be worked on, not because it's ready to assign.
Note: skipped standards alignment beyond the existing 9-12.CT.5 tag for this reason -- the content (magic methods, type-checking, tuples vs. lists) is still just a bullet list in the devnote below, not written lab text, so there's not enough here yet to judge honestly against csta2026 or to double-check CT.5. Revisit once this lab is actually written.
In this lab we will use object-oriented programming to work with ideas from geometry, specifically points, vectors, and lines. So far we have only used object-oriented programming to create games--this makes sense since object-oriented programming is all about creating models and a game is basically just a model of specific actions and goals.
>>> from geometry.point import Point
>>> from geometry.vector import Vector
>>> pt = Point((1, 1))
>>> vec = Vector((4, 0))
>>> pt - vec