// a class for working with stripes/sets of parallel lines
// lines defined ba ax+by=shift+k; where k is integer
// this makes sets of parallel lines as
// used in "projection method-geometry and maths"
// see the post "How to shift the design" for translations by (xTrans,yTrans)
class Stripes{
float a,b,shift;
int kmax;
Stripes(float angle,float sp){
a=cos(angle);
b=sin(angle);
shift=sp+a*xTrans+b*yTrans;
shift=shift-floor(shift);
// determine lines ax+by=c at corners of screen - maximum value for kmax=c-shift
kmax=2*int(abs(a)*xRange+abs(b)*yRange)+2;
}
// get k-value (real number) for a given point (class Vector) p
float getK(Vector p){
return a*p.x+b*p.y-shift;
}
// get intersection with line of other stripe set with choosen k-values
Vector intersection(Stripes stripe,int k,int ki){
float x,y,den;
den=1./(a*stripe.b-b*stripe.a);
x=den*((shift+k)*stripe.b-b*(stripe.shift+ki));
y=den*(a*(stripe.shift+ki)-(shift+k)*stripe.a);
return new Vector(x,y);
}
}

### Like this:

Like Loading...

*Related*