[ot][spam][crazy][crazy][spam]

Undiscussed Horrific Abuse, One Victim of Many gmkarl at gmail.com
Sun May 15 08:39:09 PDT 2022


#include <stdio.h>

int grid[5*5] = {0};

typedef struct pt {
  int x;
  int y;
} pt;

void plot(pt p)
{
  grid[p.x+p.y*5] = 1;
}


pt pt1 = {2,1};
pt pt2 = {4,3};
pt pt3 = {0,3};


void line(pt a, pt b)
{
  pt change = {b.x - a.x, b.y - a.y};
  int ctx = change.x > 0 ? change.x : -change.x;
  int cty = change.y > 0 ? change.y : -change.y;
  int ct = ctx > cty ? ctx : cty;
  for (int t = 0; t <= ct; ++ t) {
    pt p = {a.x + change.x * t / ct, a.y + change.y * t / ct};
    plot(p);
  }
}

int main()
{
  line(pt1, pt2);
  line(pt2, pt3);
  line(pt3, pt1);

  for (int y = 0; y < 5; y ++) {
    for (int x = 0; x < 5; x ++)
      printf("%d", grid[x + y * 5]);
    printf("\n");
  }
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/html
Size: 1767 bytes
Desc: not available
URL: <https://lists.cpunks.org/pipermail/cypherpunks/attachments/20220515/28b991d9/attachment.txt>


More information about the cypherpunks mailing list