Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (221)

View Page History

{zone-data:revision}
2.0 - 02 Jun 2011: Finished the proposal code so that it can be reviewed.
1.0 - 29 May 2011: Initial Draft.
{zone-data}
* Zend_Math_BoundingFrustum
* Zend_Math_BoundingSphere
* Zend_Math_BoundingVolume
* Zend_Math_Exception
* Zend_Math_Exception_DivideByZero
{zone-data}

{zone-data:skeletons}{code}<?php
{code}<?php

/**
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Math
class Zend_Math_BoundingBox extends Zend_Math_BoundingVolume
{
/**
* The value PI.
* Checks if this bounding volume contains the given value.
* @const
*/
const PI = 3.1415926535897932384626433832795028841971693993751;

/**
* Two times the value of PI.
* @const
*/
const PI2 = 6.283185307179586476925286766559;

/**
* The half of PI.
* @const
*/
const HALF_PI = 1.5707963267948966192313216916398;

/**
* The reciprocal value of PI.
* @const
*/
const RECIPROCAL_PI = 0.31830988618379067153776752674503;

/**
* The factor to convert degrees to radians.
* @const
*/
const DEG_TO_RAD = 0.0174532925;

/**
* The factor to convert radians to degrees.
* @const
*/
const RAD_TO_DEG = 57.2957795;

/**
* Converts the given radians to degrees.
* @param float $value The value to convert.
* @return float Returns the converted value.
*/
public static function degToRad( $value )
{
return $value * self::DEG_TO_RAD;
}

/**
* Converts the given degrees to radians.
* @param float $value The value to convert.
* @return float Returns the converted value.
*/
public static function radToDeg( $value )
{
return $value * self::RAD_TO_DEG;
}

/**
* Clamps the given value between the given minimum and maximum.
* @param mixed $value The value that should be clamped.
* @param mixed $min The minimum value.
* @param mixed $max The maximum value.
* @return mixed Returns the clamped value.
*/
public static function clamp( $value, $min, $max )
{
return max( $min, min( $value, $max ) );
}

/**
* Lineair interpolates the two values.
* @param mixed $from The value to start from.
* @param mixed $to The value to interpolate to.
* @param mixed $amount The amount of interpolation to apply.
* @return mixed Returns the interpolated value.
*/
public static function lerp( $from, $to, $amount )
{
return $from + ( $to - $from ) * $amount;
}
}
{code}

{code}<?php

/**
* @category Zend
* @package Zend_Math
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Math_BoundingBox
{
/**
* Checks if this bounding box contains the given value.
* @param mixed $value The value to check for.
* @return bool Returns true when this bounding box volume contains the given value; false otherwise.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function contains( $value )
{
}
else
{
throw new InvalidArgumentException( 'Invalid argument provided.' );
}
return $result;
}

/**
* Checks if this bounding box volume intersects with the given value.
*
* @param mixed $value The value to check for.
* @return bool Returns true when this bounding box volume intersects with the given value; false otherwise.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function intersects( $value )
{
}
else
{
throw new InvalidArgumentException( 'Invalid argument provided.' );
}
return $result;
}
} }{code}
{code}

{code}<?php
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Math_BoundingFrustum extends Zend_Math_BoundingVolume
{
/**
* Checks if this bounding frustum volume contains the given value.
*
* @param mixed $value The value to check for.
* @return bool Returns true when this bounding frustum volume contains the given value; false otherwise.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function contains( $value )
{
}
else
{
throw new InvalidArgumentException( 'Invalid argument provided.' );
}
return $result;
}

/**
* Checks if this bounding frustum volume intersects with the given value.
*
* @param mixed $value The value to check for.
* @return bool Returns true when this bounding frustum volume intersects with the given value; false otherwise.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function intersects( $value )
{
}
else
{
throw new InvalidArgumentException( 'Invalid argument provided.' );
}
return $result;
}
} }{code}
{code}

{code}<?php
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Math_BoundingSphere extends Zend_Math_BoundingVolume
{
/**
* Checks if this bounding sphere volume contains the given value.
*
* @param mixed $value The value to check for.
* @return bool Returns true when this bounding sphere volume contains the given value; false otherwise.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function contains( $value )
{
}
else
{
throw new InvalidArgumentException( 'Invalid argument provided.' );
}
return $result;
}

/**
* Checks if this bounding sphere volume intersects with the given value.
*
* @param mixed $value The value to check for.
* @return bool Returns true when this bounding sphere volume intersects with the given value; false otherwise.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function intersects( $value )
{
}
else
{
throw new InvalidArgumentException( 'Invalid argument provided.' );
}
return $result;
}
} }{code}
{code}

{code}<?php
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Math_Exception extends Zend_Exception
abstract class Zend_Math_BoundingVolume
{
} /**
{code}
* Checks if this bounding volume contains the given value.
*
* @param mixed $value The value to check for.
* @return bool Returns true when this bounding volume contains the given value; false otherwise.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public abstract function contains( $value );

/**
* Checks if this bounding volume intersects with the given value.
*
* @param mixed $value The value to check for.
* @return bool Returns true when this bounding volume intersects with the given value; false otherwise.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public abstract function intersects( $value );
}{code}

{code}<?php

class Zend_Math_Exception_DivideByZero extends Zend_Math_Exception
{
} }{code}
{code}

{code}<?php
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Math_Exception extends Zend_Exception
{
}{code}

{code}<?php

/**
* @category Zend
* @package Zend_Math
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Math_Interface
{
/**
* Adds the given value to this value.
*
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function add( $value );
/**
* Subtracts the given value from this value.
*
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function sub( $value );
/**
* Multiplies this value with the given value.
*
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function mul( $value );
/**
* Divides this value by the given value.
*
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function div( $value );
/**
* Converts this value to a readable string.
*
* @return string
*/
public function __toString();
} }{code}
{code}

{code}<?php
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Math_Matrix_Matrix44 extends Zend_Math_Matrix
{
/**
* Initializes a new instance of this class.
*/
public function __construct()
{
parent::__construct( 4, 4 );
}

/**
* Creates a scale matrix.
*
* @param mixed $X The X-position to set. This can be a number or a vector.
* @param mixed $Y The Y-position to set. This should be a number or empty when $X is a vector.
* @param mixed $Z The Z-position to set. This should be a number or empty when $X is a vector.
* @return Zend_Math_Matrix Returns a new instance of this class.
* @throws InvalidArgumentException When the given argument is not valid.
*/
public static function createScale( $X = 0.0, $Y = 0.0, $Z = 0.0 )
{
$result = new self();
if ( is_float( $X ) || is_int( $X ) )
{
$result->set( 0, 0, $X );
$result->set( 1, 1, $Y );
$result->set( 2, 2, $Z );
}
else if ( $X instanceof Zend_Math_Vector_Vector3 || $X instanceof Zend_Math_Vector_Vector4 )
{
$result->set( 0, 0, $X->getX() );
$result->set( 1, 1, $X->getY() );
$result->set( 2, 2, $X->getZ() );
}
else
{
throw new InvalidArgumentException( 'No valid argument provided.' );
}
return $result;
}

/**
* Creates a translation matrix.
*
* @param mixed $X The X-position to set. This can be a number or a vector.
* @param mixed $Y The Y-position to set. This should be a number or empty when $X is a vector.
* @param mixed $Z The Z-position to set. This should be a number or empty when $X is a vector.
* @return Zend_Math_Matrix Returns a new instance of this class.
* @throws InvalidArgumentException When the given argument is not valid.
*/
public static function createTranslation( $X = 0.0, $Y = 0.0, $Z = 0.0 )
{
$result = new self();
if ( is_float( $X ) || is_int( $X ) )
{
$result->set( 0, 3, $X );
$result->set( 1, 3, $Y );
$result->set( 2, 3, $Z );
}
else if ( $X instanceof Zend_Math_Vector_Vector3 || $X instanceof Zend_Math_Vector_Vector4 )
{
$result->set( 0, 3, $X->getX() );
$result->set( 1, 3, $X->getY() );
$result->set( 2, 3, $X->getZ() );
}
else
{
throw new InvalidArgumentException( 'No valid argument provided.' );
}
return $result;
}

/**
* Creates a rotation matrix around the X-axis.
*
* @param float $radians The radians to set.
* @return Zend_Math_Matrix Returns a new instance of this class.
*/
public static function createRotationX( $radians = 0.0 )
{
$result = new self();

// @todo

return $result;
}

/**
* Creates a rotation matrix around the Y-axis.
*
* @param float $radians The radians to set.
* @return Zend_Math_Matrix Returns a new instance of this class.
*/
public static function createRotationY( $radians = 0.0 )
{
$result = new self();

// @todo

return $result;
}

/**
* Creates a rotation matrix around the Z-axis.
* @param float $radians The radians to set.
* @return Zend_Math_Matrix Returns a new instance of this class.
*/
public static function createRotationZ( $radians = 0.0 )
{
$result = new self();

// @todo

return $result;
}
}{code}

{code}<?php

/**
* @category Zend
* @package Zend_Math
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Math_Matrix implements Zend_Math_Interface, Iterator
{
/**
* The position of the iterator.
*
* @var int
*/
/**
* The amount of components that this matrix has.
*
* @var array
*/
/**
* The amount of rows that this matrix has.
*
* @var int
*/
/**
* The amount of columns that this matrix has.
*
* @var int
*/
/**
* Initializes a new instance of this class.
*
* @param int $rows The amount of rows that this matrix has.
* @param int $columns The amount of columns that this matrix has.
/**
* Gets the amount of rows that this matrix has.
*
* @return int
*/
/**
* Gets the amount of columns that this matrix has.
*
* @return int
*/
/**
* Gets the given component.
*
* @return float
* @throws OutOfBoundsException When the row or column is not valid.
*/
public function get( $row, $column )
/**
* Sets the value to the given component.
*
* @param int $row The row to set.
* @param int $column The column to set.
* @param float $value The value to set.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws OutOfBoundsException When the row or column is not valid.
*/
public function set( $row, $column, $value )
return $this;
}

/**
* Adds the given value to this value.
*
* @param $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws OutOfBoundsException When the argument is a matrix but not of the same dimension.
* @throws InvalidArgumentException When the given argument is not a valid value.
*/
public function add( $value )
/**
* Subtracts the given value from this value.
*
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws OutOfBoundsException When the argument is a matrix but not of the same dimension.
* @throws InvalidArgumentException When the given argument is not a valid value.
*/
public function sub( $value )
/**
* Multiplies this value with the given value.
*
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws InvalidArgumentException When the given argument is not a valid value.
*/
public function mul( $value )
/**
* Divides this value by the given value.
*
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws InvalidArgumentException When the given argument is not a valid value.
*/
public function div( $value )
/**
* Makes an identity matrix of this matrix.
*
* @return Zend_Math_Matrix Returns the instance of this class.
*/
/**
* Calculates the determinant of this matrix.
*
* @return float Returns the determinant of this matrix.
* @throws RuntimeException When this is not a square matrix.
*/
public function determinant()
/**
* Calculate the 'minor' of the given matrix at given position. The minor is the matrix formed by deleting the specified row and column from the matrix.
*
* @param Zend_Math_Matrix $matrix The matrix to work with.
* @param int $row The row to remove.
/**
* Transposes the rows and columns of this matrix and returns a new matrix.
*
* @return Zend_Math_Matrix Returns a new instance of this class containing the transposed matrix.
*/
/**
* Gets the current value from the iterator.
*
* @return mixed Returns the current value of the iterator.
*/
/**
* Gets the current key from the iterator.
*
* @return int Returns the current key of the iterator.
*/
/**
* Increases the iterator's position.
*
* @return void
*/
/**
* Rewinds the iterator's position.
*
* @return void
*/
/**
* Checks if the iterator is still valid.
*
* @return boolean Returns true when the iterator is valid; false otherwise.
*/
/**
* Converts this value to a readable string.
*
* @return string
*/
return implode( ',', $this->_components );
}
} }{code}
{code}

{code}
<?php

/**
* @category Zend
* @package Zend_Math
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Math_Matrix_Matrix44 extends Zend_Math_Matrix
{
/**
* Initializes a new instance of this class.
*/
public function __construct()
{
parent::__construct( 4, 4 );
}

/**
* Creates a scale matrix.
*
* @param mixed $X The X-position to set. This can be a number or a vector.
* @param mixed $Y The Y-position to set. This should be a number or empty when $X is a vector.
* @param mixed $Z The Z-position to set. This should be a number or empty when $X is a vector.
* @return Zend_Math_Matrix Returns a new instance of this class.
*/
public static function createScale( $X = 0.0, $Y = 0.0, $Z = 0.0 )
{
$result = new self();
if ( is_float( $X ) || is_int( $X ) )
{
$result->set( 0, 0, $X );
$result->set( 1, 1, $Y );
$result->set( 2, 2, $Z );
}
else if ( $X instanceof Zend_Math_Vector_Vector3 || $X instanceof Zend_Math_Vector_Vector4 )
{
$result->set( 0, 0, $X->getX() );
$result->set( 1, 1, $X->getY() );
$result->set( 2, 2, $X->getZ() );
}
return $result;
}

/**
* Creates a translation matrix.
*
* @param mixed $X The X-position to set. This can be a number or a vector.
* @param mixed $Y The Y-position to set. This should be a number or empty when $X is a vector.
* @param mixed $Z The Z-position to set. This should be a number or empty when $X is a vector.
* @return Zend_Math_Matrix Returns a new instance of this class.
*/
public static function createTranslation( $X = 0.0, $Y = 0.0, $Z = 0.0 )
{
$result = new self();
if ( is_float( $X ) || is_int( $X ) )
{
$result->set( 0, 3, $X );
$result->set( 1, 3, $Y );
$result->set( 2, 3, $Z );
}
else if ( $X instanceof Zend_Math_Vector_Vector3 || $X instanceof Zend_Math_Vector_Vector4 )
{
$result->set( 0, 3, $X->getX() );
$result->set( 1, 3, $X->getY() );
$result->set( 2, 3, $X->getZ() );
}
return $result;
}

/**
* Creates a rotation matrix around the X-axis.
*
* @param float $radians The radians to set.
* @return Zend_Math_Matrix Returns a new instance of this class.
*/
public static function createRotationX( $radians = 0.0 )
{
$result = new self();

// @todo

return $result;
}

/**
* Creates a rotation matrix around the Y-axis.
*
* @param float $radians The radians to set.
* @return Zend_Math_Matrix Returns a new instance of this class.
*/
public static function createRotationY( $radians = 0.0 )
{
$result = new self();

// @todo

return $result;
}

/**
* Creates a rotation matrix around the Z-axis.
*
* @param float $radians The radians to set.
* @return Zend_Math_Matrix Returns a new instance of this class.
*/
public static function createRotationZ( $radians = 0.0 )
{
$result = new self();

// @todo

return $result;
}
}
{code}

{code}<?php

/**
* The distance of the plane.
*
* @var float
*/
/**
* The normal vector of the plane.
*
* @var Zend_Math_Vector_Vector3
*/
/**
* Initializes a new instance of this class.
*
* @param float $distance The distance of this plane.
* @param Zend_Math_Vector_Vector3 $normal The normal of this plane.
*/
public function __construct( $distance, Zend_Math_Vector_Vector3 $normal )
/**
* Gets the distance of this plane related to the math origin.
*
* @return float Returns the distance of this plane from the math origin.
*/
/**
* Gets the normal of this plane.
*
* @return Zend_Math_Vector_Vector3 Returns a Zend_Math_Vector_Vector3 which represents the normal of this plane.
*/
return $this->_normal;
}
} }{code}
{code}

{code}<?php
/**
* The X-position of the point.
*
* @var float
*/
/**
* The Y-position of the point.
*
* @var float
*/
/**
* Initializes a new instance of this class.
*
* @param $x The X-position of this point.
* @param $y The Y-position of this point.
/**
* Gets the X-position of this point.
*
* @return float Returns a float representing the X-position of this point.
*/
/**
* Gets the Y-position of this point.
*
* @return float Returns a float representing the Y-position of this point.
*/
return $this->_y;
}
} }{code}
{code}

{code}<?php
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Math_Quaternion implements Zend_Math_Interface
{
} /**
{code}
* The X-component of this quaternion.
*
* @var float
*/
private $X;

/**
* The Y-component of this quaternion.
*
* @var float
*/
private $Y;

/**
* The Z-component of this quaternion.
*
* @var float
*/
private $Z;

/**
* The W-component of this quaternion.
*
* @var float
*/
private $W;

/**
* Initializes a new instance of this class.
*
* @param float $X The X-component to set.
* @param float $Y The Y-component to set.
* @param float $Z The Z-component to set.
* @param float $W The W-component to set.
*/
public function __construct( $X, $Y, $Z, $W )
{
$this->X = $X;
$this->Y = $Y;
$this->Z = $Z;
$this->W = $W;
}

/**
* Gets the X-component of this quaternion.
*
* @return float
*/
public function getX()
{
return $this->X;
}

/**
* Gets the Y-component of this quaternion.
*
* @return float
*/
public function getY()
{
return $this->Y;
}

/**
* Gets the Z-component of this quaternion.
*
* @return float
*/
public function getZ()
{
return $this->Z;
}

/**
* Gets the W-component of this quaternion.
*
* @return float
*/
public function getW()
{
return $this->W;
}

/**
* Calculates the dot product of this quaternion and the given quaternion.
*
* @param Zend_Math_Quaternion $value The quaternion to calculate with.
* @return float Returns the dot product between the two quaternions.
*/
public function dot( Zend_Math_Quaternion $value )
{
$result = 0.0;
return $result;
}

/**
* Calculates the conjugate of this quaternion.
*
* @return Zend_Math_Quaternion Returns the instance of this class.
*/
public function conjugate()
{
$this->X = -$this->X;
$this->Y = -$this->Y;
$this->Z = -$this->Z;
$this->W = -$this->W;
return $this;
}

/**
* Calculates the length of this quaternion.
*
* @return float Returns the length of this quaternion.
*/
public function length()
{
$result = 1.0;
return $result;
}

/**
* Normalizes this quaternion.
*
* @return Zend_Math_Quaternion Returns the instance of this quaternion.
*/
public function normalize()
{
$cloned = clone $this;
$cloned->div( $this->length() );

$this->X = $cloned->getX();
$this->Y = $cloned->getY();
$this->Z = $cloned->getZ();
$this->W = $cloned->getW();

return $this;
}

/**
* Creates a quaternion with no rotation.
*
* @return Zend_Math_Quaternion Returns the identity quaternion.
*/
public static function createIdentity()
{
return new Zend_Math_Quaternion( 0.0, 0.0, 0.0, 1.0 );
}

/**
* Creates a quaternion from the given yaw, pitch and roll value.
*
* @param float $yaw The angle in radians around the Y-axis.
* @param float $pitch The angle in radians around the X-axis.
* @param float $roll The angle in radians around the Z-axis.
* @return Zend_Math_Quaternion Returns the created quaternion.
*/
public static function createFromYawPitchRoll( $yaw, $pitch, $roll )
{
return new Zend_Math_Quaternion( 0.0, 0.0, 0.0, 1.0 );
}

/**
* Adds the given value to this value.
*
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function add( $value )
{
return $this;
}

/**
* Subtracts the given value from this value.
*
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function sub( $value )
{
return $this;
}

/**
* Multiplies this value with the given value.
*
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function mul( $value )
{
return $this;
}

/**
* Divides this value by the given value.
*
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function div( $value )
{
return $this;
}

/**
* Converts this value to a readable string.
*
* @return string
*/
public function __toString()
{
return implode( ',', array(
$this->X, $this->Y, $this->Z, $this->W,
) );
}
}{code}

{code}<?php

/**
* The direction of this ray.
*
* @var Zend_Math_Vector_Vector3
*/
/**
* The position of this ray.
*
* @var Zend_Math_Vector_Vector3
*/
/**
* Initializes a new instance of this class.
*
* @param Zend_Math_Vector_Vector3 $position The position of the ray.
* @param Zend_Math_Vector_Vector3 $direction The direction of the ray.
/**
* Gets the direction of this ray.
*
* @return Zend_Math_Vector_Vector3 Returns a Zend_Math_Vector_Vector3 which represents the direction.
*/
/**
* Gets the position of this ray.
*
* @return Zend_Math_Vector_Vector3 Returns a Zend_Math_Vector_Vector3 which represents the position.
*/
/**
* Checks if this ray intersects with the given value.
*
* @param mixed $value The value to calculate with.
* @return bool Returns true when there is an intersection; false otherwise.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function intersects( $value )
if ( $value instanceof Zend_Math_BoundingBox )
{
// @todo
}
else if ( $value instanceof Zend_Math_BoundingFrustum )
{
// @todo
}
else if ( $value instanceof Zend_Math_BoundingSphere )
{
// @todo
}
else if ( $value instanceof Zend_Math_Plane )
{
// @todo
}
else
return $result;
}
} }{code}
{code}

{code}<?php
/**
* The X-position of the rectangle.
*
* @var float
*/
/**
* The Y-position of the rectangle.
*
* @var float
*/
/**
* The width of the rectangle.
*
* @var float
*/
/**
* The height of the rectangle.
*
* @var float
*/
/**
* Initializes a new instance of this class.
*
* @param float $x The X-position of this rectangle.
* @param float $y The Y-position of this rectangle.
* @param float $width The width of this rectangle.
* @param float $height The height of this rectangle.
*/
public function __construct( $x, $y, $width, $height )
/**
* Gets the X-position of this rectangle.
*
* @return float Returns a float representing the X-position of this rectangle.
*/
/**
* Gets the Y-position of this rectangle.
*
* @return float Returns a float representing the Y-position of this rectangle.
*/
/**
* Gets the width of this rectangle.
*
* @return float Returns the width of this rectangle.
*/
/**
* Gets the height of this rectangle.
*
* @return float Returns the height of this rectangle.
*/
/**
* Gets the X-position of the left of this rectangle.
*
* @return float Returns a float representing the X-position of the left of this rectangle.
*/
/**
* Gets the Y-position of the top of this rectangle.
*
* @return float Returns a float representing the Y-position of the top of this rectangle.
*/
/**
* Gets the X-position of the right of this rectangle.
*
* @return float Returns a float representing the X-position of the right of this rectangle.
*/
/**
* Gets the Y-position of the bottom of this rectangle.
*
* @return float Returns a float representing the Y-position of the bottom of this rectangle.
*/
/**
* Gets the location of this rectangle.
*
* @return Point Returns a Point object which represents the location of this rectangle.
*/
/**
* Gets the size of this rectangle.
*
* @return Size Returns a Size object which represents the size of this rectangle.
*/
/**
* Checks if the given value is inside the rectangle.
*
* @param mixed $x The X-position, point or rectangle value to check for.
* @param mixed $y The Y-position to check for.
* @return bool Returns true when the given value is inside this rectangle; false otherwise.
* @throws InvalidArgumentException When the given argument is not valid.
*/
public function contains( $x = 0.0, $y = 0.0 )
/**
* Pushes the edges of this rectangle out by the given amount.
*
* @param mixed $horizontalAmount The value to push the sides out.
* @param mixed $verticalAmount The value to push the top and bottom out.
/**
* Checks if the given rectangle intersects with this rectangle.
*
* @param Zend_Math_Rectangle $value The value to check for.
* @return bool Returns true if the rectangle intersect; false otherwise.
/**
* Changes the location of this rectangle.
*
* @param mixed $X The change in the X-position.
* @param mixed $y The change in the Y-position.
* @return Zend_Math_Rectangle Returns the updated instance of this class.
* @throws InvalidArgumentException When the given argument is not valid.
*/
public function offset( $x = 0.0, $y = 0.0 )
return $this;
}
} }{code}
{code}

{code}<?php
/**
* The width of the size.
*
* @var float
*/
/**
* The height of the size.
*
* @var float
*/
/**
* Initializes a new instance of this class.
*
* @param float $width The width of this size.
* @param float $height The height of this size.
*/
public function __construct( $width, $height )
/**
* Gets the width of this size.
*
* @return float Returns the width of this size.
*/
/**
* Gets the height of this size.
*
* @return float Returns the height of this size.
*/
return $this->_height;
}
} }{code}
{code}

{code}<?php
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Math_Vector implements Zend_Math_Interface, Iterator
{
/**
* The position of the iterator.
* @var int
*/
private $_position = 0;

/**
* The amount of components that this vector has.
* @var array
*/
protected $_components = array();

/**
* Initializes a new instance of this class.
* @param int $components The amount of components that this vector has.
*/
public function __construct( $components )
{
$this->_components = array_fill( 0, $components, 0.0 );
}

/**
* Gets the dimension of this vector.
* @return int Returns an integer which represents the dimension of this vector.
*/
public function getDimension()
{
return count( $this->_components );
}

/**
* Gets the given component.
* @return float
*/
public function get( $component )
{
return $this->_components[ $component ];
}

/**
* Sets the value to the given component.
* @param int $component The component to set.
* @param float $value The value to set.
* @return Zend_Math_Interface Returns the instance of this object.
*/
public function set( $component, $value )
{
if ( $component < $this->getDimension() )
{
$this->_components[ $component ] = $value;
}
else
{
throw new OutOfBoundsException( 'Trying to set component index ' . $component . ' while this vector only has ' . $this->getDimension() . ' components.' );
}
return $this;
}
/**
* Adds the given value to this value.
* @param $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
*/
public function add( $value )
{
if ( $value instanceof Zend_Math_Vector )
{
foreach ( $value as $component => $componentValue )
{
$this->_components[ $component ] += $componentValue;
}
}
else if ( is_int( $value ) || is_float( $value ) )
{
foreach ( $this->_components as $component => $componentValue )
{
$this->_components[ $component ] += $value;
}
}
return $this;
}

/**
* Subtracts the given value from this value.
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
*/
public function sub( $value )
{
if ( $value instanceof Zend_Math_Vector )
{
foreach ( $value as $component => $componentValue )
{
$this->_components[ $component ] -= $componentValue;
}
}
else if ( is_int( $value ) || is_float( $value ) )
{
foreach ( $this->_components as $component => $componentValue )
{
$this->_components[ $component ] -= $value;
}
}
return $this;
}

/**
* Multiplies this value with the given value.
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
*/
public function mul( $value )
{
if ( $value instanceof Zend_Math_Vector )
{
foreach ( $value as $component => $componentValue )
{
$this->_components[ $component ] *= $componentValue;
}
}
else if ( is_int( $value ) || is_float( $value ) )
{
foreach ( $this->_components as $component => $componentValue )
{
$this->_components[ $component ] *= $value;
}
}
return $this;
}

/**
* Divides this value by the given value.
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
*/
public function div( $value )
{
if ( $value instanceof Zend_Math_Vector )
{
foreach ( $value as $component => $componentValue )
{
if ( !$componentValue )
{
throw new Zend_Math_Exception_DivideByZero( 'A value cannot be divided by zero.' );
}
$this->_components[ $component ] /= $componentValue;
}
}
else if ( is_int( $value ) || is_float( $value ) )
{
if ( !$value )
{
throw new Zend_Math_Exception_DivideByZero( 'A value cannot be divided by zero.' );
}

foreach ( $this->_components as $component => $componentValue )
{
$this->_components[ $component ] /= $value;
}
}
return $this;
}

/**
* Calculates the dot product of this vector and the given vector.
* @param Zend_Math_Vector $value The vector to calculate with.
* @return float Returns the dot product between the two vectors.
*/
public function dot( Zend_Math_Vector $value )
{
if ( $this->getDimension() != $value->getDimension() )
{
throw new RuntimeException( 'We can only calculate the dot product between two vectors with the same dimension.' );
}

$result = 0.0;
foreach ( $value as $component => $componentValue )
{
$result += ( $this->_components[ $component ] * $componentValue );
}
return $result;
}

/**
* Calculates the length of this vector.
* @return float Returns the length of this vector.
*/
public function length()
{
$result = 0.0;
foreach ( $this->_components as $component => $value )
{
$result += ( $value * $value );
}
return sqrt( $result );
}

/**
* Calculates the lineair interpolation between the given vectors.
* @param Zend_Math_Vector $vector1 The vector to interpolte from.
* @param Zend_Math_Vector $vector2 The vector to interpolte to.
* @param float $amount The weight value. This is a value between 0.0 and 1.0.
* @return Zend_Math_Vector Returns a vector containing the interpolated values.
*/
public final static function lerp( Zend_Math_Vector $vector1, Zend_Math_Vector $vector2, $amount )
{
if ( $vector1->getDimension() != $vector2->getDimension() )
{
throw new InvalidArgumentException( 'Vectors must be of the same dimension.' );
}

$result = clone $vector1;

for ( $i = 0; $i < $result->getDimension(); ++$i )
{
$val1 = $vector1->get( $i );
$val2 = $vector2->get( $i );
$result->set( $i, $val1 + ( $val2 - $val1 ) * $amount );
}

return $result;
}

/**
* Negates this vector.
* @return Zend_Math_Vector Returns the instance of this vector.
*/
public function negate()
{
foreach ( $this->_components as $component => $value )
{
$this->_components[ $component ] = -$value;
}

return $this;
}

/**
* Normalizes this vector.
* @return Zend_Math_Vector Returns the instance of this vector.
*/
public function normalize()
{
$cloned = clone $this;
$cloned->div( $this->length() );

foreach ( $this->_components as $component => $value )
{
$this->_components[ $component ] = $cloned->get( $component );
}

return $this;
}

/**
* Gets the current value from the iterator.
* @return mixed Returns the current value of the iterator.
*/
public function current()
{
return $this->_components[ $this->_position ];
}

/**
* Gets the current key from the iterator.
* @return int Returns the current key of the iterator.
*/
public function key()
{
return $this->_position;
}

/**
* Increases the iterator's position.
* @return void
*/
public function next()
{
++$this->_position;
}

/**
* Rewinds the iterator's position.
* @return void
*/
public function rewind()
{
$this->_position = 0;
}

/**
* Checks if the iterator is still valid.
* @return boolean Returns true when the iterator is valid; false otherwise.
*/
public function valid()
{
return $this->_position < $this->getDimension();
}

/**
* Converts this value to a readable string.
* @return string
*/
public function __toString()
{
return implode( ',', $this->_components );
}
}
{code}

{code}<?php

/**
* @category Zend
* @package Zend_Math
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Math_Vector_Vector2 extends Zend_Math_Vector
{
/**
* Initializes a new instance of this class.
*
* @param float $X The X-value of this vector.
* @param float $Y The Y-value of this vector.
/**
* Gets the X-value of this vector.
*
* @return float Returns the X-value as a float value.
*/
/**
* Sets the X-value of this vector.
*
* @param float @value The value to set.
* @return Zend_Math_Vector_Interface Returns the instance of this class.
/**
* Gets the Y-value of this vector.
*
* @return float Returns the Y-value as a float value.
*/
/**
* Sets the Y-value of this vector.
*
* @param float @value The value to set.
* @return Zend_Math_Vector_Interface Returns the instance of this class.
/**
* Gets the zero vector.
*
* @return Zend_Math_Vector2 Returns the zero vector.
*/
/**
* Gets the X-unit vector.
*
* @return Zend_Math_Vector3 Returns the X-unit vector.
*/
/**
* Gets the Y-unit vector.
*
* @return Zend_Math_Vector3 Returns the Y-unit vector.
*/
return new Zend_Math_Vector2( 0.0, 1.0 );
}
} }{code}
{code}

{code}<?php
/**
* Initializes a new instance of this class.
*
* @param float $X The X-value of this vector.
* @param float $Y The Y-value of this vector.
/**
* Gets the X-value of this vector.
*
* @return float Returns the X-value as a float value.
*/
/**
* Sets the X-value of this vector.
*
* @param float @value The value to set.
* @return Zend_Math_Vector_Interface Returns the instance of this class.
/**
* Gets the Y-value of this vector.
*
* @return float Returns the Y-value as a float value.
*/
/**
* Sets the Y-value of this vector.
*
* @param float @value The value to set.
* @return Zend_Math_Vector_Interface Returns the instance of this class.
/**
* Gets the Z-value of this vector.
*
* @return float Returns the Z-value as a float value.
*/

/**
* Sets the Z-value of this vector.
*
* @param float @value The value to set.
* @return Zend_Math_Vector_Interface Returns the instance of this class.
/**
* Gets the zero vector.
*
* @return Zend_Math_Vector_Vector3 Returns the zero vector.
*/
/**
* Gets the X-unit vector.
*
* @return Zend_Math_Vector_Vector3 Returns the X-unit vector.
*/
/**
* Gets the Y-unit vector.
*
* @return Zend_Math_Vector_Vector3 Returns the Y-unit vector.
*/
/**
* Gets the Z-unit vector.
*
* @return Zend_Math_Vector_Vector3 Returns the Z-unit vector.
*/
/**
* Calculates the cross product of this vector and the given vector.
*
* @param Zend_Math_Vector_Vector3 $value The vector to calculate with.
* @return Zend_Math_Vector_Vector3 Returns the cross product between the two vectors.
* @throws InvalidArgumentException When the given vector is not of the same dimension as this vector.
*/
public function cross( Zend_Math_Vector_Vector3 $value )
if ( $this->getDimension() != $value->getDimension() )
{
throw new RuntimeException( InvalidArgumentException( 'We can only calculate the cross product between two vectors with the same dimension.' );
}

return $result;
}
} }{code}
{code}

{code}<?php
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Math_Vector_Vector34 extends Zend_Math_Vector
{
/**
* Initializes a new instance of this class.
*
* @param float $X The X-value of this vector.
* @param float $Y The Y-value of this vector.
/**
* Gets the X-value of this vector.
*
* @return float Returns the X-value as a float value.
*/
/**
* Sets the X-value of this vector.
*
* @param float @value The value to set.
* @return Zend_Math_Vector_Interface Returns the instance of this class.
/**
* Gets the Y-value of this vector.
*
* @return float Returns the Y-value as a float value.
*/
/**
* Sets the Y-value of this vector.
*
* @param float @value The value to set.
* @return Zend_Math_Vector_Interface Returns the instance of this class.
/**
* Gets the Z-value of this vector.
*
* @return float Returns the Z-value as a float value.
*/
/**
* Sets the Z-value of this vector.
*
* @param float @value The value to set.
* @return Zend_Math_Vector_Interface Returns the instance of this class.
/**
* Gets the W-value of this vector.
*
* @return float Returns the W-value as a float value.
*/
/**
* Sets the W-value of this vector.
*
* @param float @value The value to set.
* @return Zend_Math_Vector_Interface Returns the instance of this class.
/**
* Gets the zero vector.
*
* @return Zend_Math_Vector4 Returns the zero vector.
*/
/**
* Gets the X-unit vector.
*
* @return Zend_Math_Vector4 Returns the X-unit vector.
*/
/**
* Gets the Y-unit vector.
*
* @return Zend_Math_Vector4 Returns the Y-unit vector.
*/
/**
* Gets the Z-unit vector.
*
* @return Zend_Math_Vector4 Returns the Z-unit vector.
*/
/**
* Gets the W-unit vector.
*
* @return Zend_Math_Vector4 Returns the W-unit vector.
*/
return new Zend_Math_Vector4( 0.0, 0.0, 0.0, 1.0 );
}
} }{code}
{code}
{code}<?php

/**
* @category Zend
* @package Zend_Math
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Math_Vector implements Zend_Math_Interface, Iterator
{
/**
* The position of the iterator.
*
* @var int
*/
private $_position = 0;

/**
* The amount of components that this vector has.
*
* @var array
*/
protected $_components = array();

/**
* Initializes a new instance of this class.
*
* @param int $components The amount of components that this vector has.
*/
public function __construct( $components )
{
$this->_components = array_fill( 0, $components, 0.0 );
}

/**
* Gets the dimension of this vector.
*
* @return int Returns an integer which represents the dimension of this vector.
*/
public function getDimension()
{
return count( $this->_components );
}

/**
* Gets the given component.
*
* @return float
*/
public function get( $component )
{
return $this->_components[ $component ];
}

/**
* Sets the value to the given component.
*
* @param int $component The component to set.
* @param float $value The value to set.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws OutOfBoundsException When the given component is not valid.
*/
public function set( $component, $value )
{
if ( $component < $this->getDimension() )
{
$this->_components[ $component ] = $value;
}
else
{
throw new OutOfBoundsException( 'Trying to set component index ' . $component . ' while this vector only has ' . $this->getDimension() . ' components.' );
}
return $this;
}

/**
* Adds the given value to this value.
*
* @param $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function add( $value )
{
if ( $value instanceof Zend_Math_Vector )
{
foreach ( $value as $component => $componentValue )
{
$this->_components[ $component ] += $componentValue;
}
}
else if ( is_int( $value ) || is_float( $value ) )
{
foreach ( $this->_components as $component => $componentValue )
{
$this->_components[ $component ] += $value;
}
}
else
{
throw new InvalidArgumentException( 'No valid argument provided.' );
}
return $this;
}

/**
* Subtracts the given value from this value.
*
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function sub( $value )
{
if ( $value instanceof Zend_Math_Vector )
{
foreach ( $value as $component => $componentValue )
{
$this->_components[ $component ] -= $componentValue;
}
}
else if ( is_int( $value ) || is_float( $value ) )
{
foreach ( $this->_components as $component => $componentValue )
{
$this->_components[ $component ] -= $value;
}
}
else
{
throw new InvalidArgumentException( 'No valid argument provided.' );
}
return $this;
}

/**
* Multiplies this value with the given value.
*
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function mul( $value )
{
if ( $value instanceof Zend_Math_Vector )
{
foreach ( $value as $component => $componentValue )
{
$this->_components[ $component ] *= $componentValue;
}
}
else if ( is_int( $value ) || is_float( $value ) )
{
foreach ( $this->_components as $component => $componentValue )
{
$this->_components[ $component ] *= $value;
}
}
else
{
throw new InvalidArgumentException( 'No valid argument provided.' );
}
return $this;
}

/**
* Divides this value by the given value.
*
* @param mixed $value The value to calculate with.
* @return Zend_Math_Interface Returns the instance of this object.
* @throws InvalidArgumentException When the given argument is not of the valid type.
*/
public function div( $value )
{
if ( $value instanceof Zend_Math_Vector )
{
foreach ( $value as $component => $componentValue )
{
if ( !$componentValue )
{
throw new Zend_Math_Exception_DivideByZero( 'A value cannot be divided by zero.' );
}
$this->_components[ $component ] /= $componentValue;
}
}
else if ( is_int( $value ) || is_float( $value ) )
{
if ( !$value )
{
throw new Zend_Math_Exception_DivideByZero( 'A value cannot be divided by zero.' );
}

foreach ( $this->_components as $component => $componentValue )
{
$this->_components[ $component ] /= $value;
}
}
else
{
throw new InvalidArgumentException( 'No valid argument provided.' );
}
return $this;
}

/**
* Calculates the dot product of this vector and the given vector.
*
* @param Zend_Math_Vector $value The vector to calculate with.
* @return float Returns the dot product between the two vectors.
* @throws InvalidArgumentException When the given argument does not have the correct dimension.
*/
public function dot( Zend_Math_Vector $value )
{
if ( $this->getDimension() != $value->getDimension() )
{
throw new InvalidArgumentException( 'We can only calculate the dot product between two vectors with the same dimension.' );
}

$result = 0.0;
foreach ( $value as $component => $componentValue )
{
$result += ( $this->_components[ $component ] * $componentValue );
}
return $result;
}

/**
* Calculates the length of this vector.
*
* @return float Returns the length of this vector.
*/
public function length()
{
$result = 0.0;
foreach ( $this->_components as $component => $value )
{
$result += ( $value * $value );
}
return sqrt( $result );
}

/**
* Negates this vector.
*
* @return Zend_Math_Vector Returns the instance of this vector.
*/
public function negate()
{
foreach ( $this->_components as $component => $value )
{
$this->_components[ $component ] = -$value;
}

return $this;
}

/**
* Normalizes this vector.
*
* @return Zend_Math_Vector Returns the instance of this vector.
*/
public function normalize()
{
$cloned = clone $this;
$cloned->div( $this->length() );

foreach ( $this->_components as $component => $value )
{
$this->_components[ $component ] = $cloned->get( $component );
}

return $this;
}

/**
* Gets the current value from the iterator.
*
* @return mixed Returns the current value of the iterator.
*/
public function current()
{
return $this->_components[ $this->_position ];
}

/**
* Gets the current key from the iterator.
*
* @return int Returns the current key of the iterator.
*/
public function key()
{
return $this->_position;
}

/**
* Increases the iterator's position.
*
* @return void
*/
public function next()
{
++$this->_position;
}

/**
* Rewinds the iterator's position.
*
* @return void
*/
public function rewind()
{
$this->_position = 0;
}

/**
* Checks if the iterator is still valid.
*
* @return boolean Returns true when the iterator is valid; false otherwise.
*/
public function valid()
{
return $this->_position < $this->getDimension();
}

/**
* Converts this value to a readable string.
*
* @return string
*/
public function __toString()
{
return implode( ',', $this->_components );
}
}{code}

{code}<?php

/**
* @category Zend
* @package Zend_Math
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Math
{
/**
* The value PI.
* @const
*/
const PI = 3.1415926535897932384626433832795028841971693993751;

/**
* Two times the value of PI.
* @const
*/
const PI2 = 6.283185307179586476925286766559;

/**
* The half of PI.
* @const
*/
const HALF_PI = 1.5707963267948966192313216916398;

/**
* The reciprocal value of PI.
* @const
*/
const RECIPROCAL_PI = 0.31830988618379067153776752674503;

/**
* The factor to convert degrees to radians.
* @const
*/
const DEG_TO_RAD = 0.0174532925;

/**
* The factor to convert radians to degrees.
* @const
*/
const RAD_TO_DEG = 57.2957795;

/**
* Converts the given radians to degrees.
* @param float $value The value to convert.
* @return float Returns the converted value.
*/
public static function degToRad( $value )
{
return $value * self::DEG_TO_RAD;
}

/**
* Converts the given degrees to radians.
* @param float $value The value to convert.
* @return float Returns the converted value.
*/
public static function radToDeg( $value )
{
return $value * self::RAD_TO_DEG;
}

/**
* Clamps the given value between the given minimum and maximum.
* @param mixed $value The value that should be clamped.
* @param mixed $min The minimum value.
* @param mixed $max The maximum value.
* @return mixed Returns the clamped value.
*/
public static function clamp( $value, $min, $max )
{
return max( $min, min( $value, $max ) );
}

/**
* Lineair interpolates the two values.
* @param mixed $from The value to start from.
* @param mixed $to The value to interpolate to.
* @param mixed $amount The amount of interpolation to apply.
* @return mixed Returns the interpolated value.
*/
public static function lerp( $from, $to, $amount )
{
$result = null;
if ( $from instanceof Zend_Math_Vector && $to instanceof Zend_Math_Vector )
{
if ( $from->getDimension() != $to->getDimension() )
{
throw new InvalidArgumentException( 'Vectors must be of the same dimension.' );
}

$result = clone $from;

for ( $i = 0; $i < $result->getDimension(); ++$i )
{
$val1 = $from->get( $i );
$val2 = $to->get( $i );
$result->set( $i, $val1 + ( $val2 - $val1 ) * $amount );
}
}
else if ( ( is_float( $from ) || is_int( $from ) ) &&
( ( is_float( $to ) || is_int( $to ) ) ) )
{
$result = $from + ( $to - $from ) * $amount;
}
else
{
throw new InvalidArgumentException( 'Invalid arguments provided for Zend_Math::lerp' );
}
return $result;
}
}{code}


{zone-data}