I’ve seen references to vec2 to create vectors in some examples. Are there any docs on how to use vec2? I’m curious if it has methods like add(), sub(), mag(), etc… and functions in a similar way to PVector in Processing. Thanks!
In a similiar vein I see vec3 in the autocomplete but not in the descriptions, is it available?
There is documentation for vec2 in the reference.
You can view it online here
Or from the browser in Codify
vec2 has overloaded operators, unlike Processing’s PVector. Here’s a quick example:
-- v1 = vec2(1,0) v2 = vec2(1,1) v3 = v1 + v2 * 2 print(v3) -- prints "(3, 2)"
You can call methods on a vec2 instance by using the colon operator, so:
normv3 = v3:normalize()
See the documentation that Dylan mentioned for the rest of the API.
Thanks! Just what I was looking for.