Skip to content
Permalink
Browse files

now with even number of dimensiosn

  • Loading branch information...
PeterStampfli committed Jun 21, 2017
1 parent fa511e7 commit 929315bd3d4373a4f18c45d6a36584d429cda61e
Showing with 28 additions and 11 deletions.
  1. +28 −11 mapping.js
@@ -77,14 +77,23 @@ var ex=[];
var ey=[];
var xTimesE=[];

function oddUnitvectors(p){
function unitvectors(p){
ex.length=p;
ey.length=p;
xTimesE.length=p;
var q=Math.floor(p/2);
for (var i=0;i<p;i++){
ex[i]=fCos(2*Math.PI*(i-q)/p);
ey[i]=fSin(2*Math.PI*(i-q)/p);
if (p&1==1){
var q=(p-1)/2;
for (var i=0;i<p;i++){
ex[i]=fCos(2*Math.PI*(i-q)/p);
ey[i]=fSin(2*Math.PI*(i-q)/p);
}
}
else {
var q=p/2;
for (var i=0;i<p;i++){
ex[i]=fCos(Math.PI*(i-q+0.5)/p);
ey[i]=fSin(Math.PI*(i-q+0.5)/p);
}
}
}

@@ -116,15 +125,23 @@ function sumSines(k){
}


function sumCosines2(k1,k2){
function sumCosines2Odd(k1,k2){
var sum=fCos(k1*xTimesE[p-1]+k2*xTimesE[0]);
for (var i=1;i<p;i++){
sum+=fCos(k1*xTimesE[i-1]+k2*xTimesE[i]);
}
return sum;
}

function sumSines2(k1,k2){
function sumCosines2Even(k1,k2){
var sum=fCos(-k1*xTimesE[p-1]+k2*xTimesE[0]);
for (var i=1;i<p;i++){
sum+=fCos(k1*xTimesE[i-1]+k2*xTimesE[i]);
}
return sum;
}

function sumSines2Odd(k1,k2){
var sum=fSin(k1*xTimesE[p-1]+k2*xTimesE[0]);
for (var i=1;i<p;i++){
sum+=fSin(k1*xTimesE[i-1]+k2*xTimesE[i]);
@@ -144,15 +161,15 @@ function quasiperiodicMapping(x,y){
xTimesUnitvectors(x,y);
imageZero();
xImage+=sumCosines(1);
yImage+=sumCosines2(1,1);
yImage+=sumCosines2Even(1,-1);
// uImage=prodCosines(1);

}

var p=5;
oddUnitvectors(p);
var p=4;
unitvectors(p);


//=====================================
var mapping=quasiperiodicMapping;
scaleOutputToInput = 200
scaleOutputToInput = 100

0 comments on commit 929315b

Please sign in to comment.
You can’t perform that action at this time.