Rail3D*

   

 


Very similar scripts to 10 Degree Points by Mark Hodson, creating double slips.


Right Hand

// Script to create a 10 degree right hand double slip

Init()
{
  node mNode=Document.GetCurrentNode();
  node Node1=mNode.GetConnectedNode(0,0);
  node Node2=mNode.GetConnectedNode(1,0);


  float x=mNode.GetX();
  float y=mNode.GetY();
  float z=mNode.GetZ();
  float alpha=mNode.GetAlpha();

  float xb=Node2.GetX();

  if(xb==0)  // Which way to go?
  {
    alpha=3.1417+alpha;
  }

  // Some useful(?) numbers
  float angle=0.1745329;  // 10 degrees
  float gauge=1.435;  // Std gauge++
  float TrackSpace=Document.GetLineSpacing();

  // Length of a 10 degree slip is 15 metres (switch to switch)
  float length=15;

  float alpha2=alpha+angle;

  // Calc position of furthest end
  float x2=x+(length*sin(alpha));
  float y2=y+(length*cos(alpha));

  // Centre
  float xc=x+((length/2.0)*sin(alpha));
  float yc=y+((length/2.0)*cos(alpha));

  // Calc position of right leg
  float x3=xc+((length/2.0)*sin(alpha2));
  float y3=yc+((length/2.0)*cos(alpha2));

  // Calc position of left leg
  float x4=xc-((length/2.0)*sin(alpha2));
  float y4=yc-((length/2.0)*cos(alpha2));

  // Build links
  Document.BuildLink(x,y,z,x2,y2,z);
  Document.BuildLink(x4,y4,z,x3,y3,z);

  Document.BuildLink(x,y,z,x3,y3,z);
  Document.BuildLink(x4,y4,z,x2,y2,z);

// Extensions for required track spacing
  float SpaceLength=TrackSpace/sin(angle);
  SpaceLength=SpaceLength-length;

// Calc position from new ends
  float xs=x2+(SpaceLength*sin(alpha));
  float ys=y2+(SpaceLength*cos(alpha));
  Document.BuildLink(x2,y2,z,xs,ys,z);

  xs=x3+(SpaceLength*sin(alpha2));
  ys=y3+(SpaceLength*cos(alpha2));
  Document.BuildLink(x3,y3,z,xs,ys,z);

  xs=x4-(SpaceLength*sin(alpha2));
  ys=y4-(SpaceLength*cos(alpha2));
  Document.BuildLink(x4,y4,z,xs,ys,z);
}

Left Hand

// Script to create a 10 degree left hand double slip

Init()
{
  node mNode=Document.GetCurrentNode();
  node Node1=mNode.GetConnectedNode(0,0);
  node Node2=mNode.GetConnectedNode(1,0);


  float x=mNode.GetX();
  float y=mNode.GetY();
  float z=mNode.GetZ();
  float alpha=mNode.GetAlpha();

  float xb=Node2.GetX();

  if(xb==0)  // Which way to go?
  {
    alpha=3.1417+alpha;
  }

  // Some useful(?) numbers
  float angle=0.1745329;  // 10 degrees
  float gauge=1.435;  // Std gauge++
  float TrackSpace=Document.GetLineSpacing();

  // Length of a 10 degree slip is 15 metres (switch to switch)
  float length=15;

  float alpha2=alpha-angle;

  // Calc position of furthest end
  float x2=x+(length*sin(alpha));
  float y2=y+(length*cos(alpha));

  // Centre
  float xc=x+((length/2.0)*sin(alpha));
  float yc=y+((length/2.0)*cos(alpha));

  // Calc position of right leg
  float x3=xc+((length/2.0)*sin(alpha2));
  float y3=yc+((length/2.0)*cos(alpha2));

  // Calc position of left leg
  float x4=xc-((length/2.0)*sin(alpha2));
  float y4=yc-((length/2.0)*cos(alpha2));

  // Build links
  Document.BuildLink(x,y,z,x2,y2,z);
  Document.BuildLink(x4,y4,z,x3,y3,z);

  Document.BuildLink(x,y,z,x3,y3,z);
  Document.BuildLink(x4,y4,z,x2,y2,z);

// Extensions for required track spacing
  float SpaceLength=TrackSpace/sin(angle);
  SpaceLength=SpaceLength-length;

// Calc position from new ends
  float xs=x2+(SpaceLength*sin(alpha));
  float ys=y2+(SpaceLength*cos(alpha));
  Document.BuildLink(x2,y2,z,xs,ys,z);

  xs=x3+(SpaceLength*sin(alpha2));
  ys=y3+(SpaceLength*cos(alpha2));
  Document.BuildLink(x3,y3,z,xs,ys,z);

  xs=x4-(SpaceLength*sin(alpha2));
  ys=y4-(SpaceLength*cos(alpha2));
  Document.BuildLink(x4,y4,z,xs,ys,z);
}

DanielEvans 30/09/2015 18:05:22