pointerToShapeLocal

The pointer in the shape's own coordinates: undo the layer's center, scale and rotation so a cursor force can act in the same space the swarm lives in (y up, isotropic).

pointerToShapeLocal(opts: {
    pointerX: number
    pointerY: number
    centerX: number
    centerYv: number
    scale: number
    rotC: number
    rotS: number
    aspect: number
}): {x: number; y: number}

Import sim from shaders/std and use sim.agentFrame.pointerToShapeLocal.

pointerX/pointerY and centerX/centerYv are in uv, rotC/rotS the cosine and sine of the rotation, aspect the canvas width over height.

Parameters

NameTypeNotes
opts`{
pointerX: number
pointerY: number
centerX: number
centerYv: number
scale: number
rotC: number
rotS: number
aspect: number

}` | |

Example

const cursor = agentFrame.pointerToShapeLocal({pointerX, pointerY, centerX, centerYv, scale, rotC, rotS, aspect})

See also

  • force — The pushes an agent can feel.