Friday, September 27, 2013

Trickzy Tikz

So I wanted to make a regular 30-gon in tikz, but was way too lazy to work out the coordinates for each vertex on my own, so here's what I came up with:

Write a file called regpoly.c containing

#include <math.h>
#include <stdio.h>

int main(int argc, char *argv[])
int i=0;
double r=2;
double n= 30;
for (i = 0; i < n; i++) {
  printf("\\draw[-] (%f,%f) -- (%f,%f);\n",r * cos(2 * M_PI * i / n), r * sin(2 * M_PI * i / n), r * cos(2 * M_PI * (i+1)/ n), r * sin(2 * M_PI * (i+1)/ n));
return 0;

compile it in the terminal by typing

cc regpoly.c -o regpoly -lm

run it by typing


Copy the resulting output into a tikzpicture in latex. Clearly one can change the number of sides the gon has by replacing 30 in line 8. Note that wordwrap has made line 10 into two lines here, it needs to be only one for it to run.

Wednesday, September 18, 2013

R make command not found linux

I'm posting this because I've just found the solution to a really silly little issue basically without the help of any of the online discussions I was able to find.

The issue was installing the 'vegan' package in R on Arch Linux. All the errors are versions of

make: command not found

This is of course appearing because you don't have the 'make' command installed, so the R package 'vegan' and it's prerequisite 'rgl' won't work without it. To fix this you need to type the following:

pacman -S base-devel
pacman -S gcc
pacman -S gcc-fortran

The make command for bash is in the base-devel group, the one for C+ is in gcc, and the one for fortran is in gcc-fortran.