Math_Vector
[ class tree: Math_Vector ] [ index: Math_Vector ] [ all elements ]

Source for file Vector3.php

Documentation is available at Vector3.php

  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Jesus M. Castagnetto <jmcastagnetto@php.net>                |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Vector3.php 304047 2010-10-05 00:25:33Z clockwerx $
  20. //
  21.  
  22.  
  23. require_once "Math/Vector.php";
  24.  
  25. /**
  26.  * 3D vector class
  27.  * Originally this class was part of NumPHP (Numeric PHP package)
  28.  *
  29.  * @author    Jesus M. Castagnetto <jmcastagnetto@php.net>
  30.  * @version    1.0
  31.  * @access    public
  32.  * @package    Math_Vector
  33.  */
  34. class Math_Vector3 extends Math_Vector {
  35.  
  36.     /**
  37.      * Constructor for Math_Vector3
  38.      *
  39.      * @access    public
  40.      * @param    mixed    $arg    an array of values, a Math_Tuple object or a Math_Vector3 object
  41.      */
  42.     function Math_Vector3($arg{
  43.         if is_array($arg&& count($arg!= 3 )
  44.             $this->tuple = null;
  45.         elseif is_object($arg&& (strtolower(get_class($arg)) != "math_vector3"
  46.                     && strtolower(get_class($arg)) != "math_tuple") )
  47.             $this->tuple = null;
  48.         elseif is_object($arg&& strtolower(get_class($arg)) == "math_tuple"
  49.                 && $arg->getSize(!= 3 )
  50.             $this->tuple = null;
  51.         else
  52.             $this->Math_Vector($arg);
  53.     }
  54.  
  55.     /**
  56.      * Returns the X component of the vector
  57.      *
  58.      * @access    public
  59.      * @return    numeric 
  60.      */
  61.     function getX()/*{{{*/
  62.     {
  63.         return $this->get(0);
  64.     }/*}}}*/
  65.  
  66.     /**
  67.      * Sets the X component of the vector
  68.      *
  69.      * @access    public
  70.      * @param    numeric    $val    the value for the Y component
  71.      * @return    mixed    true on success, PEAR_Error object otherwise
  72.      */
  73.     function setX($val)/*{{{*/
  74.     {
  75.         return $this->set(0$val);
  76.     }/*}}}*/
  77.  
  78.     /**
  79.      * Returns the Y component of the vector
  80.      *
  81.      * @access    public
  82.      * @return    numeric 
  83.      */
  84.     function getY()/*{{{*/
  85.     {
  86.         return $this->get(1);
  87.     }/*}}}*/
  88.  
  89.     /**
  90.      * Sets the Y component of the vector
  91.      *
  92.      * @access    public
  93.      * @param    numeric    $val    the value for the Y component
  94.      * @return    mixed    true on success, PEAR_Error object otherwise
  95.      */
  96.     function setY($val)/*{{{*/
  97.     {
  98.         return $this->set(1$val);
  99.     }/*}}}*/
  100.  
  101.     /**
  102.      * Returns the Z component of the vector
  103.      *
  104.      * @access    public
  105.      * @return    numeric 
  106.      */
  107.     function getZ()/*{{{*/
  108.     {
  109.         return $this->get(2);
  110.     }/*}}}*/
  111.  
  112.     /**
  113.      * Sets the Z component of the vector
  114.      *
  115.      * @access    public
  116.      * @param    numeric    $val    the value for the Y component
  117.      * @return    mixed    true on success, PEAR_Error object otherwise
  118.      */
  119.     function setZ($val)/*{{{*/
  120.     {
  121.         return $this->set(2$val);
  122.     }/*}}}*/
  123.  
  124. }
  125.  
  126. ?>

Documentation generated on Mon, 11 Mar 2019 15:39:22 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.