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

Source for file Vector2.php

Documentation is available at Vector2.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: Vector2.php 304047 2010-10-05 00:25:33Z clockwerx $
  20. //
  21.  
  22. require_once "Math/Vector.php";
  23.  
  24. /**
  25.  * 2D Vector class
  26.  * Originally this class was part of NumPHP (Numeric PHP package)
  27.  *
  28.  * @author    Jesus M. Castagnetto <jmcastagnetto@php.net>
  29.  * @version    1.0
  30.  * @access    public
  31.  * @package    Math_Vector
  32.  */
  33. class Math_Vector2 extends Math_Vector {
  34.  
  35.     /**
  36.      * Constructor for Math_Vector2
  37.      *
  38.      * @access    public
  39.      * @param    mixed    $arg    an array of values, a Math_Tuple object or a Math_Vector2 object
  40.      */
  41.     function Math_Vector2($arg/*{{{*/
  42.     {
  43.         if is_array($arg&& count($arg!= 2 )
  44.             $this->tuple = null;
  45.         elseif is_object($arg&& (strtolower(get_class($arg)) != "math_vector2"
  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(!= 2 )
  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.  
  103. ?>

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