crazy-spider

sol = Solve[{l1^2 == x1^2 + x2^2, l2^2 == y1^2 + y2^2, p1 == x1 + y1, 
     p2 == x2 + y2}, {x1, y1, x2, y2}] // 
   FullSimplify[#, p2 > 0 && p1 > 0] &;
Manipulate[
 Graphics[
  Table[With[{mp1 = 1.3 ml1 - 2*Cos[T]*(Cos[T] + α)/4 + 1/4, 
     mp2 = Sin[T]*(Sin[T] + β)/4 + 1/4},
    {RGBColor[0, 0, 0, ((T - t)/10 π)^2], 
         Line[{{0, 0}, {x2, -x1}, {x2 + y2, -x1 - y1}}]} /. # & /@ 
      sol[[{1}]] /. {p1 -> mp1, p2 -> mp2, l1 -> ml1, l2 -> ml2}
    ], {T, t, t + 2 π, 2 π/10}], 
  PlotRange -> {{-10, 10}, {-10, 0}}
  ],
 {ml1, 6, 10},
 {ml2, 3, 10},
 {t, 0, 2 π, Appearance -> "Open"},
 {{α, 2}, 2, 4},
 {{β, 10}, 2, 10}
 ]

spider http://asdfg.me/spider/

xx = false;

demos.spider = {};
demos.spider.initWorld = function(world) {
    ground = world.m_groundBody;

	// create spider body
	var spiderBoxDef = new b2BoxDef(); 
	spiderBoxDef.extents.Set(150,20);
	spiderBoxDef.density = 0.1;

	var spiderBodyDef = new b2BodyDef(); 
	spiderBodyDef.AddShape( spiderBoxDef );
	spiderBodyDef.allowSleep = false; 
	spiderBodyDef.position.Set(500/2, 90);

	var spiderBody = world.CreateBody( spiderBodyDef );
	spiderBody.strokeStyle="#ff0000";

	// Define spider leg.
	var sd = new b2BoxDef();
	sd.extents.Set(1, 25);
	sd.density = 1.0;
	sd.friction = 0.9; 
	sd.isSensor = true; 

	var bd = new b2BodyDef();
	bd.allowSleep = false;
	bd.AddShape(sd);

	var lowerLegBoxDef = new b2BoxDef();
	lowerLegBoxDef.extents.Set(1, 15);
	lowerLegBoxDef.density = 1; 
	lowerLegBoxDef.friction = 0.9; 

	var lowerLegBodyDef = new b2BodyDef();
	lowerLegBodyDef.AddShape(lowerLegBoxDef);


	var prevBody = ground;



	var N = 18; 
	for( var i = 0; i < N; i++ ){
		var rjd = new b2RevoluteJointDef();
		var x = 500/2 + (i-(N-1)/2)*15; 
		bd.position.Set(x, 140);
		var body = world.CreateBody(bd);
		body.strokeStyle = "#ffff00";
		rjd.anchorPoint.Set(x, 110);
		rjd.body1 = spiderBody;
		rjd.body2 = body;
		rjd.motorSpeed = 0;
		rjd.motorTorque = 5000000000000.0;
		rjd.enableMotor = true;
		rjd.enableLimit = false; 
		rjd.lowerLimit = -3.5;
		rjd.upperLimit = 3.5; 
		rjd.collideConnected = false;
		console.log(rjd);
		var upperJoint = world.CreateJoint(rjd);
		xx = upperJoint; 

		// Define follower.
		lowerLegBodyDef.position.Set(x, 180);
		var lowerLegBody = world.CreateBody(lowerLegBodyDef);

		rjd.anchorPoint.Set(x, 165);
		rjd.body1 = body;
		rjd.body2 = lowerLegBody;
		rjd.motorSpeed = 0;
		rjd.motorTorque = 500000000000000.0;
		rjd.enableMotor = true;
		rjd.collideConnected = false;
		j = world.CreateJoint(rjd);
		j.upperJoint = upperJoint; 
		xx = j;
		j.s = Math.PI*4*i/N; 
		j.onDraw = function(){
			this.s += 0.05; 
			this.s %= 2*Math.PI;
			var target = Math.cos(this.s)*0.4; 

			var l1 = 25;
			var l2 = 15; 
			var A = 2; 
			var B = 4; 
			var scale = 4; 
			var mp1 = 0.9*l1-Math.cos(this.s)*(Math.cos(this.s)+A)*scale*0.9;
			var mp2 = Math.sin(this.s)*(Math.sin(this.s)+B)*scale;


			var p1 = mp1; // p1 and p2 are messed up
			var p2 = mp2; 

			var l1sq = l1*l1; 
			var l1cu = l1sq*l1;
			var l2sq = l2*l2;
			var p1sq = p1*p1;
			var p1cu = p1sq*p1;
			var p2sq = p2*p2;
			var p2cu = p2sq*p2;
			var sq = Math.sqrt(-(-(l1-l2)*(l1-l2)+p1sq+p2sq)*(-(l1+l2)*(l1+l2)+p1sq+p2sq)); 
			var div = 2*(p1sq+p2sq); 
			var x1 = (l1sq*p1 - l2sq*p1 + p1cu + p1*p2sq - p2*sq )/div;
			var y1 = (-l1sq*p1 + p1*(l2sq+p1sq+p2sq) + p2*sq)/div;
			var x2 = ( (l1sq-l2sq+p1sq)*p2 + p2cu + p1*sq )/div;
			var y2 = -(l1sq*p2 - p2*(l2sq+p1sq+p2sq) + p1*sq )/div;
			var constr=function(x,a){ return Math.max(-a,Math.min(x,a));};
			var alpha = Math.atan2( x2, x1 ); 
			var beta = Math.atan2( y2, y1 ); 
			this.SetMotorSpeed( constr(beta-this.GetJointAngle(),1.5) );
			this.upperJoint.SetMotorSpeed( constr(alpha - this.upperJoint.GetJointAngle(), 1.5) );
		}


	}

	prevBody = body;
}
demos.InitWorlds.push(demos.spider.initWorld);
youtube

1974 / Crazy Spider / Gum Bisquit / Piedino Il Questurino / OST (Soundtrack) EMI Parlophone Records (Italy)

OST 45 single by GUM BISQUIT; Italian pressing on EMI. Incredible example of Italian psychedelic delirium! Acid Funk with sinister fuzz guitars in Alessandroni style… reminding us of The Devils Nightmare aka La Notte Terrificante Del Demonio. (Soundtrack)

youtube

dancing spider