1 /** 2 * @class vector 3 * @description 4 * 5 * A hybrid class suitable for both 2D and 3D 6 * positional and physics operations. See {@link sandboxe.vector.create} 7 * 8 */ 9 function vector() { 10 11 12 /** 13 * Returns the length of the vector. 14 * 15 * @returns {Number} 16 */ 17 this.length = function(){}; 18 19 /** 20 * Instantiates a new vector that is a copy of this one's data. 21 * @returns {vector} 22 */ 23 this.clone = function(){}; 24 25 /** 26 * Returns this vector in string form 27 * @returns {String} 28 */ 29 this.toString = function(){}; 30 31 /** 32 * Gets the non-directional distance between 2 vectors as positions. 33 * @param {vector} other 34 */ 35 this.distance = function(){}; 36 37 /** 38 * Sets this vector to a normalized form where its length becomes 1.0. 39 */ 40 this.normalized = function(){}; 41 42 /** 43 * Returns the dot product of the two vectors. 44 * 45 * The dot product is defined as 46 * (a.length() * b.length() * cos(\theta)) 47 * where theta is the angle between the 2 vectors 48 * @param {vector} b 49 * @returns {Number} 50 */ 51 this.dot = function(){}; 52 53 /** 54 * Returns the 2D cross product => this x other. 55 * 56 * A cross product is computed as if the z components 57 * were equal to zero. This gives the magnitude, or Z of 58 * the cross product. 59 * @param {vector} other 60 * @returns {Number} 61 */ 62 this.cross2D = function(){}; 63 64 /** 65 * Returns the cross product of this vector and another in that order. 66 * @param {vector} other 67 * @returns {Number} 68 */ 69 this.cross = function(){}; 70 71 72 73 74 /** 75 * returns the YZ angle between the 2 76 * vectors in relation to the origin in degrees 77 * @param {vector} 78 * @returns {Number} 79 */ 80 this.rotationXDiff = function(){}; 81 82 /** 83 * returns the angle between the 2 84 * vectors in relation to this vector in degrees 85 * @param {vector} 86 * @returns {Number} 87 */ 88 this.rotationXDiffRelative = function(){}; 89 90 /** 91 * X axis rotation in degrees 92 * 93 * If a vector has length zero in these dimensions 94 * , the angle is always zero. 95 * The rotation is about the directional vector (1, 0, 0) and 96 * Positive rotation is towards the positive Z direction. 97 * @returns {Number} 98 */ 99 this.rotationX = function(){}; 100 101 102 103 104 105 106 /** 107 * returns the ZX angle between the 2 108 * vectors in relation to the origin in degrees 109 * @param {vector} 110 * @returns {Number} 111 */ 112 this.rotationYDiff = function(){}; 113 114 /** 115 * returns the angle between the 2 116 * vectors in relation to this vector in degrees 117 * @param {vector} 118 * @returns {Number} 119 */ 120 this.rotationYDiffRelative = function(){}; 121 122 /** 123 * Y axis rotation in degrees 124 * 125 * If a vector has length zero in these dimensions 126 * , the angle is always zero. 127 * The rotation is about the directional vector (0, 1, 0) and 128 * Positive rotation is towards the positive X direction. 129 * @returns {Number} 130 */ 131 this.rotationY = function(){}; 132 133 134 135 136 137 /** 138 * returns the XY angle between the 2 139 * vectors in relation to the origin in degrees 140 * @param {vector} 141 * @returns {Number} 142 */ 143 this.rotationZDiff = function(){}; 144 145 /** 146 * returns the angle between the 2 147 * vectors in relation to this vector in degrees 148 * @param {vector} 149 * @returns {Number} 150 */ 151 this.rotationZDiffRelative = function(){}; 152 153 /** 154 * Z axis rotation in degrees 155 * 156 * These deal with angles between the x and y axes. 157 * XY is most useful for 2D angles and transformations. 158 * If a vector has length zero in these dimensions 159 * , the angle is always zero. 160 * The rotation is about the directional vector (0, 0, 1). 161 * Positive rotation is towards the positive Y direction. 162 * @returns {Number} 163 */ 164 this.rotationZ = function(){}; 165 166 167 168 169 170 /** 171 * Rotates the directional vector about the {1, 0, 0} axis in degrees. 172 * @param {Number} 173 174 */ 175 this.rotateX = function(){}; 176 177 /** 178 * Rotates the directional vector about the {0, 1, 0} axis in degrees. 179 * @param {Number} 180 */ 181 this.rotateY = function(){}; 182 183 /** 184 * Rotates the directional vector about the {0, 0, 1} axis in degrees. 185 * @param {Number} 186 */ 187 this.rotateZ = function(){}; 188 189 190 191 /** 192 * Rotates the directional vector about the {1, 0, 0} axis in degrees from a different origin. 193 * @param {vector} 194 * @param {Number} 195 */ 196 this.rotateXFrom = function(){}; 197 198 /** 199 * Rotates the directional vector about the {0, 1, 0} axis in degrees from a different origin. 200 * @param {vector} 201 * @param {Number} 202 */ 203 this.rotateYFrom = function(){}; 204 205 /** 206 * Rotates the directional vector about the {0, 0, 1} axis in degrees from a different origin. 207 * @param {vector} 208 * @param {Number} 209 */ 210 this.rotateZFrom = function(){}; 211 212 213 214 215 /** 216 * X component of the vector 217 * @type {Number} 218 */ 219 this.x = {}; 220 221 /** 222 * Y component of the vector 223 * @type {Number} 224 */ 225 this.y = {}; 226 227 /** 228 * Z component of the vector 229 * @type {Number} 230 */ 231 this.z = {}; 232 233 234 return this; 235 }