Most cases of premature ejaculation do not have a clear cause. With sexual experience and age, men often learn to delay orgasm. Premature ejaculation may occur with a new partner, only in certain sexual situations, or if it has been a long time since the last ejaculation. Psychological factors such as anxiety, guilt, or depression can cause premature ejaculation. In some cases, premature ejaculation may be related to a medical cause such as hormonal problems, injury, or a side effect of certain medicines. Quick flash to our customers: order cialis online uk no rx if you need generic cialis and get fast delivery to london. Worrying that you won't be able to perform in bed can make it harder for you to do just that. Anxiety from other parts of your life can also spill over into the bedroom. Full information about Kamagra product line by Adjanta - buy kamagra online in uk.

Sloppy twisty worm

February 9th, 2009

In this worm, the pieces are all chained together and each piece is rotated 180 degrees on its base.

MEL code follows:


// find the center of a face
proc vector centerOfFace(string $face) {
  // get locations of all vertices in an array
  float $pos[] = `xform -q -ws -t ($face)`;
  // get length of the array: # vertices * 3
  int $posSize = size($pos);
  // put the average of all vectors into 1st vector 
  for ($i = 0; $i < 3; $i++){
    for ($j = $i + 3; $j < $posSize; $j += 3){
      $pos[$i] += $pos[$j];
    $pos[$i] /= ($posSize / 3);
  return <<$pos[0], $pos[1], $pos[2]>>;

// given three distances, get angle with law of cosines
proc float getAngle(float $distance) {
  // law of cosines: cos angle c = a^2+b^2-c^2/2ab
  $cSquared = `pow $distance 2`;
  // a and b in this case are both 1
  $cosAngleC = (2-$cSquared)/2;
  // fix rare sloppiness
  if ($cosAngleC < -1) {$cosAngleC = -1;}
  // solve for angle with arccosine, in degrees
  $degrees = `acosd $cosAngleC`;
  // round to two decimal places to account for roundoff
  $degrees = (floor(($degrees+.005)*100))/100;
  // get angle to closest corner
  return $degrees % 120;

//get distance between two vertices
proc float getDistance(string $vertA, string $vertB) {
  // get location of both vertices
  vector $aLoc = `xform -q -ws -t $vertA`;
  vector $bLoc = `xform -q -ws -t $vertB`;
  // get difference between two locations
  vector $cLoc = <<$aLoc.x-$bLoc.x, $aLoc.y-$bLoc.y, $aLoc.z-$bLoc.z>>;
  return mag($cLoc);

proc doit() {
// make a regular tetrahedron and select it
select `polyCone -r 1 -h 1.414214 -sx 3`;
// move its pivot point to the bottom face
xform -rp 0 -0.707107 0;
// move to origin and freeze xforms
xform -t 0 0.707107 0;
makeIdentity -apply true -t 1;

// turn off constraint warnings
cycleCheck -e off;

$old = `ls -sl`;

for ($i=1; $i<500; ++$i) {
  // copy cone
  $new = `duplicate $old[0]`;
  if ($i != 1) {parent -w $new;} // move to world space

  // pick a random face on $old that isn't the base
  int $r = rand(3)+1;
  $selectedFace = ( $old[0] + ".f[" + $r + "]" );

  // move $new to selected face
  vector $fc = centerOfFace($selectedFace);
  xform -a -t ($fc.x) ($fc.y) ($fc.z) $new[0];

  // aim $new at face with a temporary normal constraint
  string $tmpConst[] = `normalConstraint -aim 0 1 0 $selectedFace $new`;
  delete $tmpConst[0];

  // pick a vertex on each pyramid
  $newVertex = $new[0]+".vtx[0]"; // 0 is on the base
  $oldVertex = $old[0]+".vtx[3]"; // 3 is the tip

  // get angle between two vertices
  $dist = getDistance($newVertex, $oldVertex);
  $angle = getAngle($dist);

  if ($angle > 0) { // if not already aligned
    // rotate $new to align the corners
    xform -r -os -ro 0 $angle 0 $new[0];
    // check the result
    $dist = getDistance($newVertex, $oldVertex);
    $angle2 = getAngle($dist);
    // if still not aligned, go the other way twice
    if ($angle2 > 0) {
      $angle *= -2;
      xform -r -os -ro 0 $angle 0 $new[0];

  // animate visibility
  setKeyframe -attribute "visibility" -v 0 -t 0 $new; 
  setKeyframe -attribute "visibility" -v 1 -t ($i+1) $new;

  // create hierarchy
  parent -a $new[0] $old[0];
  $old = $new;
// animate rotations
select -all -hi;
setKeyframe -attribute "rotateX" -t 1 -ott flat; 
setKeyframe -attribute "rotateY" -t 1 -ott flat; 
setKeyframe -attribute "rotateZ" -t 1 -ott flat; 
currentTime 500;
xform -r -os -ro 0 180 0;
setKeyframe -attribute "rotateX" -t 500;
setKeyframe -attribute "rotateY" -t 500;
setKeyframe -attribute "rotateZ" -t 500;
// for some reason the -tt flags don't work on setKeyframe
keyTangent -attribute "rotateX" -t 500 -itt flat -ott flat;
keyTangent -attribute "rotateY" -t 500 -itt flat -ott flat;
keyTangent -attribute "rotateZ" -t 500 -itt flat -ott flat;

cycleCheck -e on;


« previously: Something I Learned Today | Home | next: 50,000 Tetrahedrons »