{"node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "revisions": [{"id": "f3382064-2f95-11f1-9e4b-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\n.. image:: http://www.foxhop.net/attachment/clock.png\r\n  :alt: analog clock vector example \r\n  :align: left\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  \r\n\r\nAnalog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\n|\r\n\r\n.. contents::\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nIn video games, vectors are used to communicate relationships of objects in space.  They can be used to move objects like players or even projectiles.  Vector math might be tedious by hand, but multiple iterations for a computer is non trivial.  Computers are great at iteration!\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help describe objects in space.  I have documented the most common vector operations used when creating 2d games.\r\n\r\nVector Operations for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n\r\nUnit Vector\r\n```````````````````\r\n\r\nIn mathematics, a unit vector can be computed for any vector.  A unit vector has the same direction as its parent but its length is 1 (the unit length).  The unit vector is very important in video games.\r\n\r\n**Syntax:**\r\n\r\n | Unit Vector = ( x / magnitude, y / magnitude )\r\n\r\n**Example:**\r\n  \r\n | v1 = (3,4)\r\n | Magnitude = 5\r\n | Unit Vector = (3/5, 4/5)\r\n\r\n\r\nScale a Vector\r\n````````````````````\r\n\r\nA vector can be multiplied or scaled by a number (scalar) to grow or shrink its magnitude.  \r\n\r\n**Syntax**\r\n    \r\n | Scaled Vector = ( x * num, y * num )\r\n\r\n**Example** \r\n\r\n | number or scaler = 3\r\n | v1 = (3,4)\r\n | Scaled Vector = (3*3,4*3) = (9,12)\r\n\r\n\r\nPython Vector Class Object\r\n-------------------------------\r\n\r\n*vector.py*\r\n\r\n.. code-block:: python\r\n :linenos:\r\n\r\n from math import sqrt\r\n\r\n class Vector( object ):\r\n\r\n    __slots__ = ('x','y')\r\n\r\n\r\n    def __init__(self, x, y):\r\n        self.x = x\r\n        self.y = y\r\n\r\n    def getLength( self ):\r\n        '''return the vectors magnitude (distance or length)'''\r\n        return sqrt( self.x ** 2 + self.y ** 2 )\r\n\r\n    def _setLength( self, val ):\r\n        '''set the vectors magnitude and alter its x and y'''\r\n        l = self.getLength()\r\n        self.x *= val / l\r\n        self.y *= val / l\r\n\r\n    length = property(\r\n        getLength, \r\n        _setLength, \r\n        None, \"Gets or Sets vector length\"\r\n    )\r\n\r\n    def scale( self, val ):\r\n        '''Scale the vector (grow or shrink)'''\r\n        return Vector( self.x * val, self.y * val )\r\n\r\n    def unit( self ):\r\n        return Vector( self.x / self.length, self.y / self.length)\r\n\r\n    def __sub__( self, v ):\r\n        return Vector( self.x - v.x, self.y - v.y )\r\n\r\n    def __add__( self, v ):\r\n        return Vector( v.x + self.x, v.y + self.y )\r\n\r\n    def __str__( self ):\r\n        return '(' + str(self.x) + ', ' + str(self.y) + ')'\r\n\r\n    # Unary Operations\r\n\r\n    def __abs__( self ):\r\n        return Vector( abs(self.x), abs(self.y) )\r\n\r\n ", "source_format": "rst", "revision_number": 26, "created": 1308706298000}, {"id": "f3381847-2f95-11f1-92a0-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\n.. image:: http://www.foxhop.net/attachment/clock.png\r\n  :alt: analog clock vector example \r\n  :align: left\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  \r\n\r\nAnalog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\n|\r\n\r\n.. contents::\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nIn video games, vectors are used to communicate relationships of objects in space.  They can be used to move objects like players or even projectiles.  Vector math might be tedious by hand, but multiple iterations for a computer is non trivial.  Computers are great at iteration!\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help describe objects in space.  I have documented the most common vector operations used when creating 2d games.\r\n\r\nVector Operations for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n\r\nUnit Vector\r\n```````````````````\r\n\r\nIn mathematics, a unit vector can be computed for any vector.  A unit vector has the same direction as its parent but its length is 1 (the unit length).  The unit vector is very important in video games.\r\n\r\n**Syntax:**\r\n\r\n | Unit Vector = ( x / magnitude, y / magnitude )\r\n\r\n**Example:**\r\n  \r\n | v1 = (3,4)\r\n | Magnitude = 5\r\n | Unit Vector = (3/5, 4/5)\r\n\r\n\r\nScale a Vector\r\n````````````````````\r\n\r\nA vector can be multiplied or scaled by a number (scalar) to grow or shrink its magnitude.  \r\n\r\n**Syntax**\r\n    \r\n | Scaled Vector = ( x * num, y * num )\r\n\r\n**Example** \r\n\r\n | number or scaler = 3\r\n | v1 = (3,4)\r\n | Scaled Vector = (3*3,4*3) = (9,12)\r\n\r\n\r\nPython Vector Class Object\r\n-------------------------------\r\n\r\n*vector.py*\r\n\r\n.. code-block:: python\r\n\r\n from math import sqrt\r\n\r\n class Vector( object ):\r\n\r\n    __slots__ = ('x','y')\r\n\r\n\r\n    def __init__(self, x, y):\r\n        self.x = x\r\n        self.y = y\r\n\r\n    def getLength( self ):\r\n        '''return the vectors magnitude (distance or length)'''\r\n        return sqrt( self.x ** 2 + self.y ** 2 )\r\n\r\n    def _setLength( self, val ):\r\n        '''set the vectors magnitude and alter its x and y'''\r\n        l = self.getLength()\r\n        self.x *= val / l\r\n        self.y *= val / l\r\n\r\n    length = property(\r\n        getLength, \r\n        _setLength, \r\n        None, \"Gets or Sets vector length\"\r\n    )\r\n\r\n    def scale( self, val ):\r\n        '''Scale the vector (grow or shrink)'''\r\n        return Vector( self.x * val, self.y * val )\r\n\r\n    def unit( self ):\r\n        return Vector( self.x / self.length, self.y / self.length)\r\n\r\n    def __sub__( self, v ):\r\n        return Vector( self.x - v.x, self.y - v.y )\r\n\r\n    def __add__( self, v ):\r\n        return Vector( v.x + self.x, v.y + self.y )\r\n\r\n    def __str__( self ):\r\n        return '(' + str(self.x) + ', ' + str(self.y) + ')'\r\n\r\n    # Unary Operations\r\n\r\n    def __abs__( self ):\r\n        return Vector( abs(self.x), abs(self.y) )\r\n\r\n ", "source_format": "rst", "revision_number": 25, "created": 1308493719000}, {"id": "f3380fe9-2f95-11f1-93a9-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\n.. image:: http://www.foxhop.net/attachment/clock.png\r\n  :alt: analog clock vector example \r\n  :align: left\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  \r\n\r\nAnalog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\n|\r\n|\r\n\r\n.. contents::\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nIn video games, vectors are used to communicate relationships of objects in space.  They can be used to move objects like players or even projectiles.  Vector math might be tedious by hand, but multiple iterations for a computer is non trivial.  Computers are great at iteration!\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help describe objects in space.  I have documented the most common vector operations used when creating 2d games.\r\n\r\nVector Operations for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n\r\nUnit Vector\r\n```````````````````\r\n\r\nIn mathematics, a unit vector can be computed for any vector.  A unit vector has the same direction as its parent but its length is 1 (the unit length).  The unit vector is very important in video games.\r\n\r\n**Syntax:**\r\n\r\n | Unit Vector = ( x / magnitude, y / magnitude )\r\n\r\n**Example:**\r\n  \r\n | v1 = (3,4)\r\n | Magnitude = 5\r\n | Unit Vector = (3/5, 4/5)\r\n\r\n\r\nScale a Vector\r\n````````````````````\r\n\r\nA vector can be multiplied or scaled by a number (scalar) to grow or shrink its magnitude.  \r\n\r\n**Syntax**\r\n    \r\n | Scaled Vector = ( x * num, y * num )\r\n\r\n**Example** \r\n\r\n | number or scaler = 3\r\n | v1 = (3,4)\r\n | Scaled Vector = (3*3,4*3) = (9,12)\r\n\r\n\r\nPython Vector Class Object\r\n-------------------------------\r\n\r\n*vector.py*\r\n\r\n.. code-block:: python\r\n\r\n from math import sqrt\r\n\r\n class Vector( object ):\r\n\r\n    __slots__ = ('x','y')\r\n\r\n\r\n    def __init__(self, x, y):\r\n        self.x = x\r\n        self.y = y\r\n\r\n    def getLength( self ):\r\n        '''return the vectors magnitude (distance or length)'''\r\n        return sqrt( self.x ** 2 + self.y ** 2 )\r\n\r\n    def _setLength( self, val ):\r\n        '''set the vectors magnitude and alter its x and y'''\r\n        l = self.getLength()\r\n        self.x *= val / l\r\n        self.y *= val / l\r\n\r\n    length = property(\r\n        getLength, \r\n        _setLength, \r\n        None, \"Gets or Sets vector length\"\r\n    )\r\n\r\n    def scale( self, val ):\r\n        '''Scale the vector (grow or shrink)'''\r\n        return Vector( self.x * val, self.y * val )\r\n\r\n    def unit( self ):\r\n        return Vector( self.x / self.length, self.y / self.length)\r\n\r\n    def __sub__( self, v ):\r\n        return Vector( self.x - v.x, self.y - v.y )\r\n\r\n    def __add__( self, v ):\r\n        return Vector( v.x + self.x, v.y + self.y )\r\n\r\n    def __str__( self ):\r\n        return '(' + str(self.x) + ', ' + str(self.y) + ')'\r\n\r\n    # Unary Operations\r\n\r\n    def __abs__( self ):\r\n        return Vector( abs(self.x), abs(self.y) )\r\n\r\n ", "source_format": "rst", "revision_number": 24, "created": 1308493709000}, {"id": "f33804d8-2f95-11f1-acb8-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\n.. image:: http://www.foxhop.net/attachment/clock.png\r\n  :alt: analog clock vector example \r\n  :align: left\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  \r\n\r\nAnalog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\n.. contents::\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nIn video games, vectors are used to communicate relationships of objects in space.  They can be used to move objects like players or even projectiles.  Vector math might be tedious by hand, but multiple iterations for a computer is non trivial.  Computers are great at iteration!\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help describe objects in space.  I have documented the most common vector operations used when creating 2d games.\r\n\r\nVector Operations for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n\r\nUnit Vector\r\n```````````````````\r\n\r\nIn mathematics, a unit vector can be computed for any vector.  A unit vector has the same direction as its parent but its length is 1 (the unit length).  The unit vector is very important in video games.\r\n\r\n**Syntax:**\r\n\r\n | Unit Vector = ( x / magnitude, y / magnitude )\r\n\r\n**Example:**\r\n  \r\n | v1 = (3,4)\r\n | Magnitude = 5\r\n | Unit Vector = (3/5, 4/5)\r\n\r\n\r\nScale a Vector\r\n````````````````````\r\n\r\nA vector can be multiplied or scaled by a number (scalar) to grow or shrink its magnitude.  \r\n\r\n**Syntax**\r\n    \r\n | Scaled Vector = ( x * num, y * num )\r\n\r\n**Example** \r\n\r\n | number or scaler = 3\r\n | v1 = (3,4)\r\n | Scaled Vector = (3*3,4*3) = (9,12)\r\n\r\n\r\nPython Vector Class Object\r\n-------------------------------\r\n\r\n*vector.py*\r\n\r\n.. code-block:: python\r\n\r\n from math import sqrt\r\n\r\n class Vector( object ):\r\n\r\n    __slots__ = ('x','y')\r\n\r\n\r\n    def __init__(self, x, y):\r\n        self.x = x\r\n        self.y = y\r\n\r\n    def getLength( self ):\r\n        '''return the vectors magnitude (distance or length)'''\r\n        return sqrt( self.x ** 2 + self.y ** 2 )\r\n\r\n    def _setLength( self, val ):\r\n        '''set the vectors magnitude and alter its x and y'''\r\n        l = self.getLength()\r\n        self.x *= val / l\r\n        self.y *= val / l\r\n\r\n    length = property(\r\n        getLength, \r\n        _setLength, \r\n        None, \"Gets or Sets vector length\"\r\n    )\r\n\r\n    def scale( self, val ):\r\n        '''Scale the vector (grow or shrink)'''\r\n        return Vector( self.x * val, self.y * val )\r\n\r\n    def unit( self ):\r\n        return Vector( self.x / self.length, self.y / self.length)\r\n\r\n    def __sub__( self, v ):\r\n        return Vector( self.x - v.x, self.y - v.y )\r\n\r\n    def __add__( self, v ):\r\n        return Vector( v.x + self.x, v.y + self.y )\r\n\r\n    def __str__( self ):\r\n        return '(' + str(self.x) + ', ' + str(self.y) + ')'\r\n\r\n    # Unary Operations\r\n\r\n    def __abs__( self ):\r\n        return Vector( abs(self.x), abs(self.y) )\r\n\r\n ", "source_format": "rst", "revision_number": 23, "created": 1308493695000}, {"id": "f337efc6-2f95-11f1-9bf0-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\n.. image:: http://www.foxhop.net/attachment/clock.png\r\n  :alt: analog clock vector example \r\n  :align: right\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  \r\n\r\nAnalog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\n.. contents::\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nIn video games, vectors are used to communicate relationships of objects in space.  They can be used to move objects like players or even projectiles.  Vector math might be tedious by hand, but multiple iterations for a computer is non trivial.  Computers are great at iteration!\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help describe objects in space.  I have documented the most common vector operations used when creating 2d games.\r\n\r\nVector Operations for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n\r\nUnit Vector\r\n```````````````````\r\n\r\nIn mathematics, a unit vector can be computed for any vector.  A unit vector has the same direction as its parent but its length is 1 (the unit length).  The unit vector is very important in video games.\r\n\r\n**Syntax:**\r\n\r\n | Unit Vector = ( x / magnitude, y / magnitude )\r\n\r\n**Example:**\r\n  \r\n | v1 = (3,4)\r\n | Magnitude = 5\r\n | Unit Vector = (3/5, 4/5)\r\n\r\n\r\nScale a Vector\r\n````````````````````\r\n\r\nA vector can be multiplied or scaled by a number (scalar) to grow or shrink its magnitude.  \r\n\r\n**Syntax**\r\n    \r\n | Scaled Vector = ( x * num, y * num )\r\n\r\n**Example** \r\n\r\n | number or scaler = 3\r\n | v1 = (3,4)\r\n | Scaled Vector = (3*3,4*3) = (9,12)\r\n\r\n\r\nPython Vector Class Object\r\n-------------------------------\r\n\r\n*vector.py*\r\n\r\n.. code-block:: python\r\n\r\n from math import sqrt\r\n\r\n class Vector( object ):\r\n\r\n    __slots__ = ('x','y')\r\n\r\n\r\n    def __init__(self, x, y):\r\n        self.x = x\r\n        self.y = y\r\n\r\n    def getLength( self ):\r\n        '''return the vectors magnitude (distance or length)'''\r\n        return sqrt( self.x ** 2 + self.y ** 2 )\r\n\r\n    def _setLength( self, val ):\r\n        '''set the vectors magnitude and alter its x and y'''\r\n        l = self.getLength()\r\n        self.x *= val / l\r\n        self.y *= val / l\r\n\r\n    length = property(\r\n        getLength, \r\n        _setLength, \r\n        None, \"Gets or Sets vector length\"\r\n    )\r\n\r\n    def scale( self, val ):\r\n        '''Scale the vector (grow or shrink)'''\r\n        return Vector( self.x * val, self.y * val )\r\n\r\n    def unit( self ):\r\n        return Vector( self.x / self.length, self.y / self.length)\r\n\r\n    def __sub__( self, v ):\r\n        return Vector( self.x - v.x, self.y - v.y )\r\n\r\n    def __add__( self, v ):\r\n        return Vector( v.x + self.x, v.y + self.y )\r\n\r\n    def __str__( self ):\r\n        return '(' + str(self.x) + ', ' + str(self.y) + ')'\r\n\r\n    # Unary Operations\r\n\r\n    def __abs__( self ):\r\n        return Vector( abs(self.x), abs(self.y) )\r\n\r\n ", "source_format": "rst", "revision_number": 22, "created": 1308493372000}, {"id": "f337e049-2f95-11f1-98a6-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\n.. image:: http://www.foxhop.net/attachment/clock.jpg\r\n  :alt: analog clock vector example \r\n  :align: right\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\n.. contents::\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nIn video games, vectors are used to communicate relationships of objects in space.  They can be used to move objects like players or even projectiles.  Vector math might be tedious by hand, but multiple iterations for a computer is non trivial.  Computers are great at iteration!\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help describe objects in space.  I have documented the most common vector operations used when creating 2d games.\r\n\r\nVector Operations for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n\r\nUnit Vector\r\n```````````````````\r\n\r\nIn mathematics, a unit vector can be computed for any vector.  A unit vector has the same direction as its parent but its length is 1 (the unit length).  The unit vector is very important in video games.\r\n\r\n**Syntax:**\r\n\r\n | Unit Vector = ( x / magnitude, y / magnitude )\r\n\r\n**Example:**\r\n  \r\n | v1 = (3,4)\r\n | Magnitude = 5\r\n | Unit Vector = (3/5, 4/5)\r\n\r\n\r\nScale a Vector\r\n````````````````````\r\n\r\nA vector can be multiplied or scaled by a number (scalar) to grow or shrink its magnitude.  \r\n\r\n**Syntax**\r\n    \r\n | Scaled Vector = ( x * num, y * num )\r\n\r\n**Example** \r\n\r\n | number or scaler = 3\r\n | v1 = (3,4)\r\n | Scaled Vector = (3*3,4*3) = (9,12)\r\n\r\n\r\nPython Vector Class Object\r\n-------------------------------\r\n\r\n*vector.py*\r\n\r\n.. code-block:: python\r\n\r\n from math import sqrt\r\n\r\n class Vector( object ):\r\n\r\n    __slots__ = ('x','y')\r\n\r\n\r\n    def __init__(self, x, y):\r\n        self.x = x\r\n        self.y = y\r\n\r\n    def getLength( self ):\r\n        '''return the vectors magnitude (distance or length)'''\r\n        return sqrt( self.x ** 2 + self.y ** 2 )\r\n\r\n    def _setLength( self, val ):\r\n        '''set the vectors magnitude and alter its x and y'''\r\n        l = self.getLength()\r\n        self.x *= val / l\r\n        self.y *= val / l\r\n\r\n    length = property(\r\n        getLength, \r\n        _setLength, \r\n        None, \"Gets or Sets vector length\"\r\n    )\r\n\r\n    def scale( self, val ):\r\n        '''Scale the vector (grow or shrink)'''\r\n        return Vector( self.x * val, self.y * val )\r\n\r\n    def unit( self ):\r\n        return Vector( self.x / self.length, self.y / self.length)\r\n\r\n    def __sub__( self, v ):\r\n        return Vector( self.x - v.x, self.y - v.y )\r\n\r\n    def __add__( self, v ):\r\n        return Vector( v.x + self.x, v.y + self.y )\r\n\r\n    def __str__( self ):\r\n        return '(' + str(self.x) + ', ' + str(self.y) + ')'\r\n\r\n    # Unary Operations\r\n\r\n    def __abs__( self ):\r\n        return Vector( abs(self.x), abs(self.y) )\r\n\r\n ", "source_format": "rst", "revision_number": 21, "created": 1308493228000}, {"id": "f337d6a8-2f95-11f1-8d8b-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\n.. image:: http://www.foxhop.net/attachment/clock.jpg\r\n  :alt: analog clock vector example \r\n  :align: right\r\n\r\n\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nIn video games, vectors are used to communicate relationships of objects in space.  They can be used to move objects like players or even projectiles.  Vector math might be tedious by hand, but multiple iterations for a computer is non trivial.  Computers are great at iteration!\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help describe objects in space.  I have documented the most common vector operations used when creating 2d games.\r\n\r\nVector Operations for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n\r\nUnit Vector\r\n```````````````````\r\n\r\nIn mathematics, a unit vector can be computed for any vector.  A unit vector has the same direction as its parent but its length is 1 (the unit length).  The unit vector is very important in video games.\r\n\r\n**Syntax:**\r\n\r\n | Unit Vector = ( x / magnitude, y / magnitude )\r\n\r\n**Example:**\r\n  \r\n | v1 = (3,4)\r\n | Magnitude = 5\r\n | Unit Vector = (3/5, 4/5)\r\n\r\n\r\nScale a Vector\r\n````````````````````\r\n\r\nA vector can be multiplied or scaled by a number (scalar) to grow or shrink its magnitude.  \r\n\r\n**Syntax**\r\n    \r\n | Scaled Vector = ( x * num, y * num )\r\n\r\n**Example** \r\n\r\n | number or scaler = 3\r\n | v1 = (3,4)\r\n | Scaled Vector = (3*3,4*3) = (9,12)\r\n\r\n\r\nPython Vector Class Object\r\n-------------------------------\r\n\r\n*vector.py*\r\n\r\n.. code-block:: python\r\n\r\n from math import sqrt\r\n\r\n class Vector( object ):\r\n\r\n    __slots__ = ('x','y')\r\n\r\n\r\n    def __init__(self, x, y):\r\n        self.x = x\r\n        self.y = y\r\n\r\n    def getLength( self ):\r\n        '''return the vectors magnitude (distance or length)'''\r\n        return sqrt( self.x ** 2 + self.y ** 2 )\r\n\r\n    def _setLength( self, val ):\r\n        '''set the vectors magnitude and alter its x and y'''\r\n        l = self.getLength()\r\n        self.x *= val / l\r\n        self.y *= val / l\r\n\r\n    length = property(\r\n        getLength, \r\n        _setLength, \r\n        None, \"Gets or Sets vector length\"\r\n    )\r\n\r\n    def scale( self, val ):\r\n        '''Scale the vector (grow or shrink)'''\r\n        return Vector( self.x * val, self.y * val )\r\n\r\n    def unit( self ):\r\n        return Vector( self.x / self.length, self.y / self.length)\r\n\r\n    def __sub__( self, v ):\r\n        return Vector( self.x - v.x, self.y - v.y )\r\n\r\n    def __add__( self, v ):\r\n        return Vector( v.x + self.x, v.y + self.y )\r\n\r\n    def __str__( self ):\r\n        return '(' + str(self.x) + ', ' + str(self.y) + ')'\r\n\r\n    # Unary Operations\r\n\r\n    def __abs__( self ):\r\n        return Vector( abs(self.x), abs(self.y) )\r\n\r\n ", "source_format": "rst", "revision_number": 20, "created": 1296380261000}, {"id": "f337cb30-2f95-11f1-bcfa-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\n.. image:: http://www.foxhop.net/attachment/clock.jpg\r\n  :alt: analog clock vector example \r\n  :align: right\r\n\r\n\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nIn video games, vectors are used to communicate relationships of objects in space.  They can be used to move objects like players or even projectiles.  Vector math might be tedious by hand, but multiple iterations for a computer is non trivial.  Computers are great at iteration!\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help describe objects in space.  I have documented the most common vector operations used when creating 2d games.\r\n\r\nVector Operations for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n\r\nUnit Vector\r\n```````````````````\r\n\r\nIn mathematics, a unit vector can be computed for any vector.  A unit vector has the same direction as its parent but its length is 1 (the unit length).  The unit vector is very important in video games.\r\n\r\n**Syntax:**\r\n\r\n | Unit Vector = ( x / magnitude, y / magnitude )\r\n\r\n**Example:**\r\n  \r\n | v1 = (3,4)\r\n | Magnitude = 5\r\n | Unit Vector = (3/5, 4/5)\r\n\r\n\r\nScale a Vector\r\n````````````````````\r\n\r\nA vector can be multiplied or scaled by a number (scalar) to grow or shrink its magnitude.  \r\n\r\n**Syntax**\r\n    \r\n | Scaled Vector = ( x * num, y * num )\r\n\r\n**Example** \r\n\r\n | number or scaler = 3\r\n | v1 = (3,4)\r\n | Scaled Vector = (3*3,4*3) = (9,12)\r\n\r\n\r\nPython Vector Class Object\r\n-------------------------------\r\n\r\n*vector.py*\r\n\r\n.. code-block:: python\r\n\r\n from math import sqrt\r\n\r\n class Vector( object ):\r\n\r\n     __slots__ = ('x','y','length')\r\n\r\n     def __init__(self, x, y):\r\n         self.x = x\r\n         self.y = y\r\n         self.length = self.getMagnitude() # distance\r\n\r\n     def getMagnitude( self ):\r\n         '''return the vectors magnitude (distance or length)'''\r\n         return sqrt( pow( self.x,2 ) + pow( self.y,2 ) )\r\n \r\n     def scale( self, num ):\r\n         '''Scale the vector (grow or shrink)'''\r\n         return Vector( self.x * num, self.y * num )\r\n\r\n     def unit( self ):\r\n         return Vector( self.x / self.length, self.y / self.length)\r\n \r\n     def __sub__( self, v ):\r\n         return Vector( v.x - self.x, v.y - self.y )\r\n\r\n     def __add__( self, v ):\r\n         return Vector( v.x + self.x, v.y + self.y )\r\n\r\n     def __str__( self ):\r\n         return '(' + str(self.x) + ', ' + str(self.y) + ')'\r\n ", "source_format": "rst", "revision_number": 19, "created": 1295652057000}, {"id": "f337bf97-2f95-11f1-9e32-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\n.. image:: http://www.foxhop.net/attachment/clock.jpg\r\n  :alt: analog clock vector example \r\n  :align: right\r\n\r\n\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nIn video games, vectors are used to communicate relationships of objects in space.  They can be used to move objects like players or even projectiles.  Vector math might be tedious by hand, but multiple iterations for a computer is non trivial.  Computers are great at iteration!\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help describe objects in space.  I have documented the most common vector operations used when creating 2d games.\r\n\r\nVector Operations for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n\r\nUnit Vector\r\n```````````````````\r\n\r\nIn mathematics, a unit vector can be computed for any vector.  A unit vector has the same direction as its parent its length is 1 (the unit length).  The unit vector is very important in video games.\r\n\r\n**Syntax:**\r\n\r\n | Unit Vector = ( x / magnitude, y / magnitude )\r\n\r\n**Example:**\r\n  \r\n | v1 = (3,4)\r\n | Magnitude = 5\r\n | Unit Vector = (3/5, 4/5)\r\n\r\n\r\nScale a Vector\r\n````````````````````\r\n\r\nA vector can be multiplied or scaled by a number (scalar) to grow or shrink its magnitude.  \r\n\r\n**Syntax**\r\n    \r\n | Scaled Vector = ( x * num, y * num )\r\n\r\n**Example** \r\n\r\n | number or scaler = 3\r\n | v1 = (3,4)\r\n | Scaled Vector = (3*3,4*3) = (9,12)\r\n\r\n\r\nPython Vector Class Object\r\n-------------------------------\r\n\r\n*vector.py*\r\n\r\n.. code-block:: python\r\n\r\n from math import sqrt\r\n\r\n class Vector( object ):\r\n\r\n     __slots__ = ('x','y','length')\r\n\r\n     def __init__(self, x, y):\r\n         self.x = x\r\n         self.y = y\r\n         self.length = self.getMagnitude() # distance\r\n\r\n     def getMagnitude( self ):\r\n         '''return the vectors magnitude (distance or length)'''\r\n         return sqrt( pow( self.x,2 ) + pow( self.y,2 ) )\r\n \r\n     def scale( self, num ):\r\n         '''Scale the vector (grow or shrink)'''\r\n         return Vector( self.x * num, self.y * num )\r\n\r\n     def unit( self ):\r\n         return Vector( self.x / self.length, self.y / self.length)\r\n \r\n     def __sub__( self, v ):\r\n         return Vector( v.x - self.x, v.y - self.y )\r\n\r\n     def __add__( self, v ):\r\n         return Vector( v.x + self.x, v.y + self.y )\r\n\r\n     def __str__( self ):\r\n         return '(' + str(self.x) + ', ' + str(self.y) + ')'\r\n ", "source_format": "rst", "revision_number": 18, "created": 1295651753000}, {"id": "f337b6d4-2f95-11f1-baa1-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\n.. image:: http://www.foxhop.net/attachment/clock.jpg\r\n  :alt: analog clock vector example \r\n  :align: right\r\n\r\n\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nVectors help keep track of space in games.  Vectors are used to move players and projectiles.  Once you learn how to do vector math, teaching the computer how is lots of fun.  Yes, programming is sort of like teaching a computer how to perform an action.\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help describe objects in space.  I have documented the most common vector operations used when creating 2d games.\r\n\r\nVector Operations for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n\r\nUnit Vector\r\n```````````````````\r\n\r\nIn mathematics, a unit vector can be computed for any vector.  A unit vector has the same direction as its parent its length is 1 (the unit length).  The unit vector is very important in video games.\r\n\r\n**Syntax:**\r\n\r\n | Unit Vector = ( x / magnitude, y / magnitude )\r\n\r\n**Example:**\r\n  \r\n | v1 = (3,4)\r\n | Magnitude = 5\r\n | Unit Vector = (3/5, 4/5)\r\n\r\n\r\nScale a Vector\r\n````````````````````\r\n\r\nA vector can be multiplied or scaled by a number (scalar) to grow or shrink its magnitude.  \r\n\r\n**Syntax**\r\n    \r\n | Scaled Vector = ( x * num, y * num )\r\n\r\n**Example** \r\n\r\n | number or scaler = 3\r\n | v1 = (3,4)\r\n | Scaled Vector = (3*3,4*3) = (9,12)\r\n\r\n\r\nPython Vector Class Object\r\n-------------------------------\r\n\r\n*vector.py*\r\n\r\n.. code-block:: python\r\n\r\n from math import sqrt\r\n\r\n class Vector( object ):\r\n\r\n     __slots__ = ('x','y','length')\r\n\r\n     def __init__(self, x, y):\r\n         self.x = x\r\n         self.y = y\r\n         self.length = self.getMagnitude() # distance\r\n\r\n     def getMagnitude( self ):\r\n         '''return the vectors magnitude (distance or length)'''\r\n         return sqrt( pow( self.x,2 ) + pow( self.y,2 ) )\r\n \r\n     def scale( self, num ):\r\n         '''Scale the vector (grow or shrink)'''\r\n         return Vector( self.x * num, self.y * num )\r\n\r\n     def unit( self ):\r\n         return Vector( self.x / self.length, self.y / self.length)\r\n \r\n     def __sub__( self, v ):\r\n         return Vector( v.x - self.x, v.y - self.y )\r\n\r\n     def __add__( self, v ):\r\n         return Vector( v.x + self.x, v.y + self.y )\r\n\r\n     def __str__( self ):\r\n         return '(' + str(self.x) + ', ' + str(self.y) + ')'\r\n ", "source_format": "rst", "revision_number": 17, "created": 1295651526000}, {"id": "f337ab9d-2f95-11f1-9a10-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\n.. image:: http://www.foxhop.net/attachment/clock.jpg\r\n  :alt: analog clock vector example \r\n  :align: right\r\n\r\n\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nVectors help keep track of space in games.  Vectors are used to move players and projectiles.  Once you learn how to do vector math, teaching the computer how is lots of fun.  Yes, programming is sort of like teaching a computer how to perform an action.\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help describe objects in space.  I have documented the most common vector operations used when creating 2d games.\r\n\r\nVector Techniques for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n\r\nUnit Vector\r\n```````````````````\r\n\r\nIn mathematics, a unit vector can be computed for any vector.  A unit vector has the same direction as its parent its length is 1 (the unit length).  The unit vector is very important in video games.\r\n\r\n**Syntax:**\r\n\r\n | Unit Vector = ( x / magnitude, y / magnitude )\r\n\r\n**Example:**\r\n  \r\n | v1 = (3,4)\r\n | Magnitude = 5\r\n | Unit Vector = (3/5, 4/5)\r\n\r\n\r\nScale a Vector\r\n````````````````````\r\n\r\nA vector can be multiplied or scaled by a number (scalar) to grow or shrink its magnitude.  \r\n\r\n**Syntax**\r\n    \r\n | Scaled Vector = ( x * num, y * num )\r\n\r\n**Example** \r\n\r\n | number or scaler = 3\r\n | v1 = (3,4)\r\n | Scaled Vector = (3*3,4*3) = (9,12)\r\n\r\n\r\nPython Vector Class Object\r\n-------------------------------\r\n\r\n*vector.py*\r\n\r\n.. code-block:: python\r\n\r\n from math import sqrt\r\n\r\n class Vector( object ):\r\n\r\n     __slots__ = ('x','y','length')\r\n\r\n     def __init__(self, x, y):\r\n         self.x = x\r\n         self.y = y\r\n         self.length = self.getMagnitude() # distance\r\n\r\n     def getMagnitude( self ):\r\n         '''return the vectors magnitude (distance or length)'''\r\n         return sqrt( pow( self.x,2 ) + pow( self.y,2 ) )\r\n \r\n     def scale( self, num ):\r\n         '''Scale the vector (grow or shrink)'''\r\n         return Vector( self.x * num, self.y * num )\r\n\r\n     def unit( self ):\r\n         return Vector( self.x / self.length, self.y / self.length)\r\n \r\n     def __sub__( self, v ):\r\n         return Vector( v.x - self.x, v.y - self.y )\r\n\r\n     def __add__( self, v ):\r\n         return Vector( v.x + self.x, v.y + self.y )\r\n\r\n     def __str__( self ):\r\n         return '(' + str(self.x) + ', ' + str(self.y) + ')'\r\n ", "source_format": "rst", "revision_number": 16, "created": 1295651490000}, {"id": "f3379b9e-2f95-11f1-bd3b-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\n.. image:: http://www.foxhop.net/attachment/clock.jpg\r\n  :alt: analog clock vector example \r\n  :align: right\r\n\r\n\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nVectors help keep track of space in games.  Vectors are used to move players and projectiles.  Once you learn how to do vector math, teaching the computer how is lots of fun.  Yes, programming is sort of like teaching a computer how to perform an action.\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help discribe objects in space by using vector techniques.  I'm going to document the vector techniques used when creating 2d games.\r\n\r\nVector Techniques for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n\r\nUnit Vector\r\n```````````````````\r\n\r\nIn mathematics, a unit vector can be computed for any vector.  A unit vector has the same direction as its parent its length is 1 (the unit length).  The unit vector is very important in video games.\r\n\r\n**Syntax:**\r\n\r\n | Unit Vector = ( x / magnitude, y / magnitude )\r\n\r\n**Example:**\r\n  \r\n | v1 = (3,4)\r\n | Magnitude = 5\r\n | Unit Vector = (3/5, 4/5)\r\n\r\n\r\nScale a Vector\r\n````````````````````\r\n\r\nA vector can be multiplied or scaled by a number (scalar) to grow or shrink its magnitude.  \r\n\r\n**Syntax**\r\n    \r\n | Scaled Vector = ( x * num, y * num )\r\n\r\n**Example** \r\n\r\n | number or scaler = 3\r\n | v1 = (3,4)\r\n | Scaled Vector = (3*3,4*3) = (9,12)\r\n\r\n\r\nPython Vector Class Object\r\n-------------------------------\r\n\r\n*vector.py*\r\n\r\n.. code-block:: python\r\n\r\n from math import sqrt\r\n\r\n class Vector( object ):\r\n\r\n     __slots__ = ('x','y','length')\r\n\r\n     def __init__(self, x, y):\r\n         self.x = x\r\n         self.y = y\r\n         self.length = self.getMagnitude() # distance\r\n\r\n     def getMagnitude( self ):\r\n         '''return the vectors magnitude (distance or length)'''\r\n         return sqrt( pow( self.x,2 ) + pow( self.y,2 ) )\r\n \r\n     def scale( self, num ):\r\n         '''Scale the vector (grow or shrink)'''\r\n         return Vector( self.x * num, self.y * num )\r\n\r\n     def unit( self ):\r\n         return Vector( self.x / self.length, self.y / self.length)\r\n \r\n     def __sub__( self, v ):\r\n         return Vector( v.x - self.x, v.y - self.y )\r\n\r\n     def __add__( self, v ):\r\n         return Vector( v.x + self.x, v.y + self.y )\r\n\r\n     def __str__( self ):\r\n         return '(' + str(self.x) + ', ' + str(self.y) + ')'\r\n ", "source_format": "rst", "revision_number": 15, "created": 1295651137000}, {"id": "f3379170-2f95-11f1-b2bb-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\n.. image:: http://www.foxhop.net/attachment/clock.jpg\r\n  :alt: analog clock vector example \r\n  :align: right\r\n\r\n\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nVectors help keep track of space in games.  Vectors are used to move players and projectiles.  Once you learn how to do vector math, teaching the computer how is lots of fun.  Yes, programming is sort of like teaching a computer how to perform an action.\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help discribe objects in space by using vector techniques.  I'm going to document the vector techniques used when creating 2d games.\r\n\r\nVector Techniques for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n\r\nUnit Vector\r\n```````````````````\r\n\r\nIn mathematics, a unit vector can be computed for any vector.  A unit vector has the same direction as its parent its length is 1 (the unit length).  The unit vector is very important in video games.\r\n\r\n**Syntax:**\r\n\r\n | Unit Vector = ( x / magnitude, y / magnitude )\r\n\r\n**Example:**\r\n  \r\n | v1 = (3,4)\r\n | Magnitude = 5\r\n | Unit Vector = (3/5, 4/5)\r\n\r\n\r\nScale a Vector\r\n````````````````````\r\n\r\nA vector can be multiplied or scaled by a number (scalar) to grow or shrink its magnitude.  \r\n\r\n**Syntax**\r\n    \r\n | Scaled Vector = ( x * num, y * num )\r\n\r\n**Example** \r\n\r\n | number or scaler = 3\r\n | v1 = (3,4)\r\n | Scaled Vector = (3*3,4*3) = (9,12)\r\n\r\n\r\n", "source_format": "rst", "revision_number": 14, "created": 1295650813000}, {"id": "f33789d9-2f95-11f1-bbea-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nVectors help keep track of space in games.  Vectors are used to move players and projectiles.  Once you learn how to do vector math, teaching the computer how is lots of fun.  Yes, programming is sort of like teaching a computer how to perform an action.\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help discribe objects in space by using vector techniques.  I'm going to document the vector techniques used when creating 2d games.\r\n\r\nVector Techniques for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n\r\nUnit Vector\r\n```````````````````\r\n\r\nIn mathematics, a unit vector can be computed for any vector.  A unit vector has the same direction as its parent its length is 1 (the unit length).  The unit vector is very important in video games.\r\n\r\n**Syntax:**\r\n\r\n | Unit Vector = ( x / magnitude, y / magnitude )\r\n\r\n**Example:**\r\n  \r\n | v1 = (3,4)\r\n | Magnitude = 5\r\n | Unit Vector = (3/5, 4/5)\r\n\r\n\r\nScale a Vector\r\n````````````````````\r\n\r\nA vector can be multiplied or scaled by a number (scalar) to grow or shrink its magnitude.  \r\n\r\n**Syntax**\r\n    \r\n | Scaled Vector = ( x * num, y * num )\r\n\r\n**Example** \r\n\r\n | number or scaler = 3\r\n | v1 = (3,4)\r\n | Scaled Vector = (3*3,4*3) = (9,12)\r\n\r\n\r\n", "source_format": "rst", "revision_number": 13, "created": 1295650330000}, {"id": "f33782be-2f95-11f1-be35-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nVectors help keep track of space in games.  Vectors are used to move players and projectiles.  Once you learn how to do vector math, teaching the computer how is lots of fun.  Yes, programming is sort of like teaching a computer how to perform an action.\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help discribe objects in space by using vector techniques.  I'm going to document the vector techniques used when creating 2d games.\r\n\r\nVector Techniques for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n\r\nUnit Vector\r\n```````````````````\r\n\r\nIn mathematics, a unit vector can be computed for any vector.  A unit vector has the same direction as its parent its length is 1 (the unit length).  The unit vector is very important in video games.\r\n\r\n**Syntax:**\r\n\r\n | Unit Vector = ( x / magnitude, y / magnitude )\r\n\r\n**Example:**\r\n  \r\n | v1 = (3,4)\r\n | Magnitude = 5\r\n | Unit Vector = (3/5, 4/5)\r\n\r\n", "source_format": "rst", "revision_number": 12, "created": 1295649225000}, {"id": "f3377a84-2f95-11f1-b77e-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nVectors help keep track of space in games.  Vectors are used to move players and projectiles.  Once you learn how to do vector math, teaching the computer how is lots of fun.  Yes, programming is sort of like teaching a computer how to perform an action.\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help discribe objects in space by using vector techniques.  I'm going to document the vector techniques used when creating 2d games.\r\n\r\nVector Techniques for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n\r\nUnit Vector\r\n```````````````````\r\n\r\nIn mathematics, a unit vector can be computed for any vector.  A unit vector has the same direction as its parent its length is 1 (the unit length).  The unit vector is very important in video games.\r\n\r\n**Syntax:**\r\n\r\n | unit vector = ( x / magnitude, y / magnitude )\r\n\r\n**Example:**\r\n  \r\n | v1 = (3,4)\r\n | Magnitude = 5\r\n | unit vector = (3/5, 4/5)\r\n\r\n", "source_format": "rst", "revision_number": 11, "created": 1295649181000}, {"id": "f33771d5-2f95-11f1-8fc9-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nVectors help keep track of space in games.  Vectors are used to move players and projectiles.  Once you learn how to do vector math, teaching the computer how is lots of fun.  Yes, programming is sort of like teaching a computer how to perform an action.\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help discribe objects in space by using vector techniques.  I'm going to document the vector techniques used when creating 2d games.\r\n\r\nVector Techniques for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n    ", "source_format": "rst", "revision_number": 10, "created": 1295646384000}, {"id": "f33768d7-2f95-11f1-b0c3-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nVectors help keep track of space in games.  Vectors are used to move players and projectiles.  Once you learn how to do vector math, teaching the computer how is lots of fun.  Yes, programming is sort of like teaching a computer how to perform an action.\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help discribe objects in space by using vector techniques.  I'm going to document the vector techniques used when creating 2d games.\r\n\r\nVector Techniques for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 ) = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n    ", "source_format": "rst", "revision_number": 9, "created": 1295646330000}, {"id": "f33760d9-2f95-11f1-9e17-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nVectors help keep track of space in games.  Vectors are used to move players and projectiles.  Once you learn how to do vector math, teaching the computer how is lots of fun.  Yes, programming is sort of like teaching a computer how to perform an action.\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help discribe objects in space by using vector techniques.  I'm going to document the vector techniques used when creating 2d games.\r\n\r\nVector Techniques for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\nVector Magnitude\r\n```````````````````\r\n\r\nA vectors magnitude (distance or length) can be calculated by the following formula:\r\n\r\n**Syntax**\r\n | Magnitude = sqrt( x^2 + y^2 )\r\n  \r\n**Example**\r\n\r\n | v1 = (3,4)\r\n | Magnitude = sqrt( 3^2 + 4^2 )\r\n | Magnitude = sqrt( 9 + 16 ) = sqrt( 25 ) = 5\r\n\r\nMagnitude doesn't always work out into a nice integer like 5 but the formula should make it easy to calculate.  \r\n\r\n    ", "source_format": "rst", "revision_number": 8, "created": 1295646250000}, {"id": "f3375663-2f95-11f1-a946-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n**Magnitude**\r\n\r\n  The size, extent, or length of a Vector.  \r\n\r\n\r\n**Direction**\r\n\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nVectors help keep track of space in games.  Vectors are used to move players and projectiles.  Once you learn how to do vector math, teaching the computer how is lots of fun.  Yes, programming is sort of like teaching a computer how to perform an action.\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help discribe objects in space by using vector techniques.  I'm going to document the vector techniques used when creating 2d games.\r\n\r\nVector Techniques for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\n  \r\n\r\n    ", "source_format": "rst", "revision_number": 7, "created": 1295644095000}, {"id": "f3374b7f-2f95-11f1-979c-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n|\r\n\r\n**Magnitude**\r\n  The size, extent, or length of a Vector.  \r\n\r\n|\r\n\r\n**Direction**\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nVectors help keep track of space in games.  Vectors are used to move players and projectiles.  Once you learn how to do vector math, teaching the computer how is lots of fun.  Yes, programming is sort of like teaching a computer how to perform an action.\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help discribe objects in space by using vector techniques.  I'm going to document the vector techniques used when creating 2d games.\r\n\r\nVector Techniques for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n**Syntax:**   \r\n\r\n | ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n**Example:**  \r\n\r\n |  v1 = (3,4)\r\n |  v2 = (4,6)\r\n |  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n\r\n | ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n | v1 = (4,2)\r\n | v2 = (3,1)\r\n | v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\n  \r\n\r\n    ", "source_format": "rst", "revision_number": 6, "created": 1295644036000}, {"id": "f3373c83-2f95-11f1-9854-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n|\r\n\r\n**Magnitude**\r\n  The size, extent, or length of a Vector.  \r\n\r\n|\r\n\r\n**Direction**\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nVectors help keep track of space in games.  Vectors are used to move players and projectiles.  Once you learn how to do vector math, teaching the computer how is lots of fun.  Yes, programming is sort of like teaching a computer how to perform an action.\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help discribe objects in space by using vector techniques.  I'm going to document the vector techniques used when creating 2d games.\r\n\r\nVector Techniques for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\nVector Addition\r\n``````````````````\r\n\r\nTwo vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\nSyntax:   \r\n\r\n  ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\nExample:  \r\n\r\n|  v1 = (3,4)\r\n|  v2 = (4,6)\r\n|  v3 = (3+4,4+6) = (7,10)\r\n\r\nVector addition is just addition of coordinate pairs. Simple right?\r\n\r\n\r\n\r\nVector Subtraction\r\n`````````````````````````````\r\n\r\nTwo vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n**Syntax**\r\n  ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n**Example**\r\n\r\n|  v1 = (4,2)\r\n|  v2 = (3,1)\r\n|  v3 = (4-3,2-1) = (1,1)\r\n\r\nVector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\n  \r\n\r\n    ", "source_format": "rst", "revision_number": 5, "created": 1295643885000}, {"id": "f3372dbc-2f95-11f1-9eaa-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n|\r\n\r\n**Magnitude**\r\n  The size, extent, or length of a Vector.  \r\n\r\n|\r\n\r\n**Direction**\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nVectors help keep track of space in games.  Vectors are used to move players and projectiles.  Once you learn how to do vector math, teaching the computer how is lots of fun.  Yes, programming is sort of like teaching a computer how to perform an action.\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help discribe objects in space by using vector techniques.  I'm going to document the vector techniques used when creating 2d games.\r\n\r\nVector Techniques for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\n**Vector Addition**\r\n  Two vectors can be added together to form a new vector.  To perform vector addition, add the x and y coordinates.\r\n\r\n  Syntax:   \r\n  ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n  Example:  \r\n  v1 = (3,4)\r\n  v2 = (4,6)\r\n  v3 = (3+4,4+6) = (7,10)\r\n\r\n  Vector addition is just addition of coordinate pairs. Simple right?\r\n\r\n**Vector Subtraction**\r\n  Two vectors can be subtracted from each other to form a new vector.  To perform vector subtraction, subtract the x and y coordinates.\r\n\r\n  Syntax:\r\n  ( v1.x - v2.x, v1.y - v2.y ) = ( v3.x, v3.y )\r\n\r\n  Example:\r\n  v1 = (4,2)\r\n  v2 = (3,1)\r\n  v3 = (4-3,2-1) = (1,1)\r\n\r\n  Vector addition is just subtraction of coordinate pairs. Again, simple right?\r\n\r\n\r\n  \r\n\r\n    ", "source_format": "rst", "revision_number": 4, "created": 1295643556000}, {"id": "f3372588-2f95-11f1-b559-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n|\r\n\r\n**Magnitude**\r\n  The size, extent, or length of a Vector.  \r\n\r\n|\r\n\r\n**Direction**\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nVectors help keep track of space in games.  Vectors are used to move players and projectiles.  Once you learn how to do vector math, teaching the computer how is lots of fun.  Yes, programming is sort of like teaching a computer how to perform an action.\r\n\r\nWhat is a vector?\r\n---------------------\r\n\r\nA vector consists of a point in space.  This document assumes knowledge about coordinates of points (x,y).  \r\n\r\nMath has developed many techniques to help discribe objects in space by using vector techniques.  I'm going to document the vector techniques used when creating 2d games.\r\n\r\nVector Techniques for 2d games\r\n----------------------------------\r\n\r\nIn the following examples we will describe two vectors, v1 and v2.\r\n \r\n**Vector Addition**\r\n  Two vectors can be added together to form a new vector.  Perform vector addition add the x and y coordinates together.\r\n\r\n  Syntax:   \r\n  ( v1.x + v2.x, v1.y + v2.y ) = ( v3.x, v3.y )\r\n  \r\n  Example:  \r\n  v1 = (3,4)\r\n  v2 = (4,6)\r\n  v3 = (3+4,4+6) = (7,10)\r\n\r\n  Simple right?  Basically it is just addition with pairs of numbers. \r\n  \r\n\r\n    ", "source_format": "rst", "revision_number": 3, "created": 1295642733000}, {"id": "f3371f84-2f95-11f1-ab89-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\n**Vector**\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n|\r\n\r\n**Magnitude**\r\n  The size, extent, or length of a Vector.  \r\n\r\n|\r\n\r\n**Direction**\r\n  The position or orientation of a vector.  Vectors point into different directions in space.\r\n\r\n\r\n\r\nHow do we use vectors in games?\r\n--------------------------------\r\n\r\nVectors help keep track of space in games.  Vectors are used to move players and projectiles.  Once you learn how to do vector math, teaching the computer how is lots of fun.  Yes, programming is sort of like teaching a computer how to perform an action.\r\n\r\nWhat is a vector\r\n---------------------\r\n\r\nA vector consists of two points in space.  This document assumes knowledge about points (x,y) coordinates.  If you do not, please research graphing points on a graph.  \r\n\r\nMath has developed many techniques to find out many things about space using vector techniques.  I'm going to document the techniques need to create 2d games.\r\n\r\nVector Techniques for 2d games\r\n----------------------------------\r\n\r\n    ", "source_format": "rst", "revision_number": 2, "created": 1295639207000}, {"id": "f33715c6-2f95-11f1-964c-e86a64d24d78", "node_id": "f336800e-2f95-11f1-910b-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Vector Math for Video Games\r\n=============================\r\n\r\nThis document outlines the common vector math formulas and terminology that is used for building 2d games.\r\n\r\nWhen introducing a new concepts such as vectors, real life examples assist in the learning process. A real life example of a vector is an analog clock.  Analog clocks have hands to represent time.  These hands could also represent vectors.  The hands much like vectors have different lengths or magnitudes.  The hands also have different directions just like the vector.\r\n\r\nTerminology\r\n--------------\r\n\r\nVector\r\n  A quantity possessing both magnitude and direction, represented by an arrow the direction of which indicates the direction of the quantity and the length of which is proportional to the magnitude.  We can represent vectors in our games to determine how to move entities in relation to each other.  \r\n\r\n[put a vector picture here]\r\n\r\nMagnitude\r\n  The size, extent, or length of a Vector.  \r\n\r\n[put a vector with large and small magnitude here]\r\n\r\nDirection\r\n  The position or orientation of a vector.  Vectors point into different directions in space.", "source_format": "rst", "revision_number": 1, "created": 1295638409000}], "count": 26}