-1

Given a direction vector from the center of one circle to another, I would like to extract different positions from where a point could go from one circle to another, being the start position perpendicular to the direction vector.

Like in this drawn:

enter image description here

I would like to generate randomly possible paths. Also, can I get the new direction vector of the possible path with just some quick operation using the center to center direction vector?

Thanks!!

Frion3L
  • 1,502
  • 4
  • 24
  • 34

1 Answers1

1

One perpendicular vector is:

p = (-v.y, v.x)

You can use this to sample possible start positions:

startPosition = center + normalize(p) * rnd(-radius, radius)

where rnd(a, b) gives a random number in [a, b].

The new direction is then simply:

dir = secondCircleCenter - startPosition
Nico Schertler
  • 32,049
  • 4
  • 39
  • 70