0
votes

I could use some help creating some points for a sliced circle, I'm having a total brainfart and just can't figure it out.

I want to create a "field of view" circle for a game ai and would like to create the points in an alternating pattern covering roughly a Pi*1.75 area.

crudely drawn illustration

1
So what have you tried an why isn't that working? - user10608418
What is the question? - Dmitry
@Dmitry, the question is how/by what to offset the theta around the "midpoint" - Insanto
Are you saying you're having trouble dividing 1.75 π by 10? - Wyck
If the angle between 10 and 11 is 1.75 π, then the angle between 10 and 8 is 0.175 π. Is that what you're asking? - Wyck

1 Answers

0
votes

To make alternate rays, you can use parity of counter. Pseudocode

n = 11
for (i = 1; i <= n; i++) {
int j = i / 2
float angle = - j * Pi * 7 / 4 / n
if (i & 1) 
  angle = - angle
line end:
  X = CX + R * Cos(angle - Pi/2))
  Y = CY + R * Sin(angle - Pi/2))

working Delphi code for demonstration:

enter image description here

var
  n, i, X, Y: Integer;
  a: Double;
begin
  n := 11;
  for i := 1 to n do begin
    Canvas.MoveTo(200, 200);
    a := (i div 2)* Pi * 7 / 4 / n;
    if (i and 1 = 0) then
      a := - a;
    X := 200 + Round(100 * Cos(a - Pi/2));
    Y := 200 + Round(100 * Sin(a - Pi/2));
    Canvas.LineTo(X, Y);
    Canvas.TextOut(X, Y, i.ToString);
  end;