Skip to content

format

typescript
Vector3.Dot(lhs, rhs)

class: Vector3

description

Calculates the dot product between two vectors.

The dot product is calculated by multiplying the corresponding components of two vectors and then adding the products together. The result of the dot product can be used for various calculations, such as determining the angle between vectors, calculating projections, determining the similarity of vectors, etc.

Features:

  • If the dot product of two vectors is a positive value, it indicates that their directions are similar and the angle between them is acute.
  • If the dot product of two vectors is zero, it indicates that they are perpendicular to each other and the angle between them is a right angle.
  • If the dot product of two vectors is a negative value, it indicates that their directions are opposite and the angle between them is obtuse.

Params:

  • lhs: Vector 1 participating in the dot product.
  • rhs: Vector 2 participating in the dot product.

Returns:

  • The dot product of the vectors.

Scripts:

typescript
let from = new Vector3(1,2,3);
let to = new Vector3(3,4,5);
Debug.Log("Dot is",Vector3.Dot(from,to));

parameter

param_nametypedescription
lhsVector3
rhsVector3

return

typedescription
number

code example