Welcome to od|forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.


VEX Penrose tile


Here is simple version based on Python implementation.

// Primitive wrangle.
// http://preshing.com/20110831/penrose-tiling-explained/

int pts[] = primpoints(0, @primnum);
vector a = point(0, "P", pts[0]);
vector b = point(0, "P", pts[1]);
vector c = point(0, "P", pts[2]);

float g = (1 + sqrt(5)) / 2;
vector p = a + (b - a) / g;
vector q = b + (a - b) / g;
vector r = b + (c - b) / g;

#define RED true
#define BLUE false
#define SAME @group_reversed
#define REVERSED !@group_reversed

void triangle(vector a, b, c; int red_or_blue, same_or_reversed)
    int prim = addprim(0, "poly");
    addvertex(0, prim, addpoint(0, a));
    addvertex(0, prim, addpoint(0, b));
    addvertex(0, prim, addpoint(0, c));
    setprimgroup(0, "red", prim, red_or_blue);
    setprimgroup(0, "reversed", prim, same_or_reversed);

if (@group_red)
    triangle(c, p, b, RED, SAME);
    triangle(p, c, a, BLUE, SAME);
    triangle(r, q, a, RED, REVERSED);
    triangle(q, r, b, BLUE, REVERSED);
    triangle(r, c, a, BLUE, SAME);

// Lengths of virtual edges to group for dissolve later.
setdetailattrib(0, "virtual_edge_long", distance(a, c));
setdetailattrib(0, "virtual_edge_short", distance(p, b));

removeprim(0, @primnum, true);


Edited by f1480187
4 people like this

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now