Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

field.align

A rotation per element turning axis onto a direction (the element's velocity v unless direction is wired), as the quaternion (x, y, z, w) an element's orient takes. A zero direction gives the identity; a direction opposite the axis gives a half turn about an axis square to it.

Inputs

  • direction (Field<Vec3> | Vec3, optional). The direction each element turns its axis onto. Left unwired, it is the element's own velocity v, which a particle solver's particles carry.
  • axis (Vec3). Default { x = 0, y = 1, z = 0 }. The element's own axis that ends up along the direction.

Outputs

  • field: a Vec4 field, the quaternion (x, y, z, w) of each element.

Example

local points = g.points.grid({ countX = 4, countZ = 1, spacing = 1 })
local out = g.attribute.set({ geometry = points, name = "v", value = g.field.align({ direction = vector.create(1, 0, 0) }) })

Every point's v holds (0, 0, -0.7071, 0.7071): a quarter turn about -z that lays +Y along +X.