MCPcopy Index your code
hub / github.com/OmkarPathak/pygorithm / dot

Method dot

pygorithm/geometry/vector2.py:249–280  ·  view source on GitHub ↗

Calculate the dot product between this vector and other. The dot product of two vectors is calculated as so:: Let v1 be a vector such that v1 = Let v2 be a vector such that v2 = v1 . v2 = v1_x * v2_

(self, other)

Source from the content-addressed store, hash-verified

247 return "<{}, {}>".format(pretty_x, pretty_y)
248
249 def dot(self, other):
250 """
251 Calculate the dot product between this vector and other.
252
253 The dot product of two vectors is calculated as so::
254
255 Let v1 be a vector such that v1 = <v1_x, v1_y>
256 Let v2 be a vector such that v2 = <v2_x, v2_y>
257
258 v1 . v2 = v1_x * v2_x + v1_y * v2_y
259
260 Example:
261
262 .. code-block:: python
263
264 from pygorithm.geometry import vector2
265
266 vec1 = vector2.Vector2(3, 5)
267 vec2 = vector2.Vector2(7, 11)
268
269 dot_12 = vec1.dot(vec2)
270
271 # prints 76
272 print(dot_12)
273
274 :param other: the other vector
275 :type other: :class:`pygorithm.geometry.vector2.Vector2`
276 :returns: the dot product of self and other
277 :rtype: :class:`numbers.Number`
278 """
279
280 return self.x * other.x + self.y * other.y
281
282 def cross(self, other):
283 """

Callers 3

test_dotMethod · 0.95
project_onto_axisMethod · 0.80
project_onto_axisMethod · 0.80

Calls

no outgoing calls

Tested by 1

test_dotMethod · 0.76