Skip to content
Maximilian Stadlmeier edited this page Jul 14, 2014 · 9 revisions

RUL.RulVec

RUL supports 2 and 3-dimensional vectors. Depending on which framework you are using this library with, the names of functions and types of parameters may differ slightly(ie. if you are using this library with Unity, replace "Vec2" with Vector2 .

2D

Vec2 RandVec2(float lowerBoundX, float lowerBoundY, float upperBoundX, float upperBoundY)

lowerBoundX : Lower limit for the x-component
lowerBoundY : Lower limit for the y-component
upperBoundX : Upper limit for the x-component
upperBoundY : Upper limit for the y-component
Returns a random 2-dimensional vector within the specified range

Vec2 RandVec2(Vec2 baseVector, float maxAngle)

baseVector : The vector that will be used as a base for the new random one
maxAngle : The greatest possible angle(in radians) between the base vector and the rotated random vector
Returns a randomly rotated version of the given base vector

Vec2 RandVec2Between(Vec2 pointA, Vec2 pointB)

pointA : One end of the line that includes the random vector
pointB : The other end of the line that includes the random vector
Returns a random 2-dimensional vector that lies on the line connecting the given points.

Vec2 RandUnitVec2()

Returns a random 2-dimensional vector with the length 1

Vec2 RandVecInCircle(float circleRadius)

circleRadius : The radius of the circle containing the random vector
Returns a random 2-dimensional vector that lies in the circle with the specified radius

Vec2 RandDirection2()

Returns a 2-dimensional vector that points up, down, left or right

3D

Most functions in this class work exactly the same way in 3-dimensional space.