print Vector::doc(); Vector::$verbose = True; $vtxO = new Vertex(array('x' => 0.0, 'y' => 0.0, 'z' => 0.0)); $vtxX = new Vertex(array('x' => 1.0, 'y' => 0.0, 'z' => 0.0)); $vtxY = new Vertex(array('x' => 0.0, 'y' => 1.0, 'z' => 0.0)); $vtxZ = new Vertex(array('x' => 0.0, 'y' => 0.0, 'z' => 1.0)); $vtcXunit = new Vector(array('orig' => $vtxO, 'dest' => $vtxX)); $vtcYunit = new Vector(array('orig' => $vtxO, 'dest' => $vtxY)); $vtcZunit = new Vector(array('orig' => $vtxO, 'dest' => $vtxZ)); print $vtcXunit . PHP_EOL; print $vtcYunit . PHP_EOL; print $vtcZunit . PHP_EOL; $dest1 = new Vertex(array('x' => -12.34, 'y' => 23.45, 'z' => -34.56)); Vertex::$verbose = True; $vtc1 = new Vector(array('dest' => $dest1)); Vertex::$verbose = False; $orig2 = new Vertex(array('x' => 23.87, 'y' => -37.95, 'z' => 78.34)); $dest2 = new Vertex(array('x' => -12.34, 'y' => 23.45, 'z' => -34.56)); $vtc2 = new Vector(array('orig' => $orig2, 'dest' => $dest2)); print 'Magnitude is ' . $vtc2->magnitude() . PHP_EOL; $nVtc2 = $vtc2->normalize(); print 'Normalized $vtc2 is ' . $nVtc2 . PHP_EOL; print 'Normalized $vtc2 magnitude is ' . $nVtc2->magnitude() . PHP_EOL; print '$vtc1 + $vtc2 is ' . $vtc1->add($vtc2) . PHP_EOL; print '$vtc1 - $vtc2 is ' . $vtc1->sub($vtc2) . PHP_EOL; print 'opposite of $vtc1 is ' . $vtc1->opposite() . PHP_EOL; print 'scalar product of $vtc1 and 42 is ' . $vtc1->scalarProduct(42) . PHP_EOL; print 'dot product of $vtc1 and $vtc2 is ' . $vtc1->dotProduct($vtc2) . PHP_EOL; print 'cross product of $vtc1 and $vtc2 is ' . $vtc1->crossProduct($vtc2) . PHP_EOL; print 'cross product of $vtcXunit and $vtcYunit is ' . $vtcXunit->crossProduct($vtcYunit) . 'aka $vtcZunit' . PHP_EOL; print 'cosinus of angle between $vtc1 and $vtc2 is ' . $vtc1->cos($vtc2) . PHP_EOL;
require_once 'Color.class.php'; require_once 'Vertex.class.php'; Color::$verbose = False; print Vertex::doc(); Vertex::$verbose = True; $vtxO = new Vertex(array('x' => 0.0, 'y' => 0.0, 'z' => 0.0)); print $vtxO . PHP_EOL; $red = new Color(array('red' => 255, 'green' => 0, 'blue' => 0)); $green = new Color(array('red' => 0, 'green' => 255, 'blue' => 0)); $blue = new Color(array('red' => 0, 'green' => 0, 'blue' => 255)); $unitX = new Vertex(array('x' => 1.0, 'y' => 0.0, 'z' => 0.0, 'color' => $green)); $unitY = new Vertex(array('x' => 0.0, 'y' => 1.0, 'z' => 0.0, 'color' => $red)); $unitZ = new Vertex(array('x' => 0.0, 'y' => 0.0, 'z' => 1.0, 'color' => $blue)); print $unitX . PHP_EOL; print $unitY . PHP_EOL; print $unitZ . PHP_EOL; Vertex::$verbose = False; $sqrA = new Vertex(array('x' => 0.0, 'y' => 0.0, 'z' => 0.0)); $sqrB = new Vertex(array('x' => 4.2, 'y' => 0.0, 'z' => 0.0)); $sqrC = new Vertex(array('x' => 4.2, 'y' => 4.2, 'z' => 0.0)); $sqrD = new Vertex(array('x' => 0.0, 'y' => 4.2, 'z' => 0.0)); print $sqrA . PHP_EOL; print $sqrB . PHP_EOL; print $sqrC . PHP_EOL; print $sqrD . PHP_EOL; $A = new Vertex(array('x' => 3.0, 'y' => 3.0, 'z' => 3.0)); print $A . PHP_EOL; $equA = new Vertex(array('x' => 9.0, 'y' => 9.0, 'z' => 9.0, 'w' => 3.0)); print $equA . PHP_EOL; Vertex::$verbose = True;