fromAngle_v2 static method

PVector fromAngle_v2(
  1. double angle,
  2. PVector? target
)

Make a new 2D unit vector from an angle

@param target the target vector (if null, a new vector will be created) @return the PVector

Implementation

static PVector fromAngle_v2(double angle, PVector? target) {
  if (target == null) {
    target = new PVector(math.cos(angle), math.sin(angle));
  } else {
    target.set(math.cos(angle), math.sin(angle), 0);
  }
  return target;
}