-- final model: Railway_and_SteamMachine -- author Anatoly Ossipov, MePHI, Moscow, Russia BOX(x[3], a[6]) { -- a[1] - center of the box on the x[1] axis -- a[2] - center of the box on the x[2] axis -- a[3] - center of the box on the x[3] axis -- a[4] - size of side on the x[1] axis -- a[5] - size of side on the x[2] axis -- a[6] - size of side on the x[3] axis array C[3]; C[1] = x[1] - a[1]; C[2] = x[2] - a[2]; C[3] = x[3] - a[3]; H_1 = a[4]/2; H_2 = a[5]/2; H_3 = a[6]/2; box = (C[1]+H_1) & (H_1-C[1]) & (C[2]+H_2) & (H_2-C[2]) & (C[3]+H_3) & (H_3-C[3]) ; } CYL_x(x[3], a[5]) { -- a[1] - center of the wheel on the x[1] axis -- a[2] - center of the wheel on the x[2] axis -- a[3] - center of the wheel on the x[3] axis -- a[4] - radius of the wheel -- a[5] - width of the wheel Cx = x[1] - a[1]; Cy = x[2] - a[2]; Cz = x[3] - a[3]; Radius = a[4]; H_Width = a[5]/2; CYL_x = (Radius - sqrt(Cy*Cy + Cz*Cz)) & (H_Width+Cx) & (H_Width-Cx); } CYL_y(x[3], a[5]) { -- a[1] - center of the wheel on the x[1] axis -- a[2] - center of the wheel on the x[2] axis -- a[3] - center of the wheel on the x[3] axis -- a[4] - radius of the wheel -- a[5] - width of the wheel Cx = x[1] - a[1]; Cy = x[2] - a[2]; Cz = x[3] - a[3]; Radius = a[4]; H_Width = a[5]/2; CYL_y = (Radius - sqrt(Cx*Cx + Cz*Cz)) & (H_Width+Cy) & (H_Width-Cy); } CYL_z(x[3], a[5]) { -- a[1] - center of the wheel on the x[1] axis -- a[2] - center of the wheel on the x[2] axis -- a[3] - center of the wheel on the x[3] axis -- a[4] - radius of the wheel -- a[5] - width of the wheel Cx = x[1] - a[1]; Cy = x[2] - a[2]; Cz = x[3] - a[3]; Radius = a[4]; H_Width = a[5]/2; CYL_z = (Radius - sqrt(Cy*Cy + Cx*Cx)) & (H_Width+Cz) & (H_Width-Cz); } railway_xz(x[3], a[9]) { -- a[1] - center of the railway on the x[1] axis -- a[2] - center of the railway on the x[2] axis -- a[3] - center of the railway on the x[3] axis -- a[4] - railway length -- a[5] - railway width -- a[6] - rut width -- a[7] - amount of sleeper -- a[8] - radius of sleeper -- a[9] - radius of rail array rail_array[5]; array ruts_array[5]; array C[3]; C[1] = x[1] - a[1]; C[2] = x[2] - a[2]; C[3] = x[3] - a[3]; -- Construct two rails: -- The first: rail_array [1] = a[1]; -- rail_array [2] = a[8]; -- (2*a[8] + 2*a[9])/2 - a[9] rail_array [3] = a[6]/2; -- rail_array [4] = a[9]; -- Cylinder radius rail_array [5] = a[4]; -- Rail1 = Cyl_x(C, rail_array); -- The first: -- Second: rail_array [3] = -a[6]/2; -- Rail2 = Cyl_x(C, rail_array); -- Construct the ruts: L_Between = a[4] / a[7]; -- Distance beetween two sleepers C_X = (-a[4] + L_Between)/2; Upper_Boundary = a[4]/2+a[8]; ruts_array [1] = C_X; ruts_array [2] = -a[9]; ruts_array [3] = 0; ruts_array [4] = a[8]; ruts_array [5] = a[5]; Ruts = Cyl_z(C, ruts_array); C_X = C_X + L_Between; while(C_X < Upper_Boundary) loop ruts_array [1] = C_X; Ruts = Ruts | Cyl_z(C, ruts_array); C_X = C_X + L_Between; endloop; railway_xz = Rail1 | Rail2 | Ruts; } Steam_Machine_X(x[3], a[6]) { -- a[1] - center of the machine on the x[1] axis -- a[2] - center of the machine on the x[2] axis -- a[3] - center of the machine on the x[3] axis -- a[4] - length of the machine -- a[5] - width of the machine -- a[6] - height of the machine array C[3]; array Wheel_Array[5]; array Wheel[3]; Cabin_D = 0.3; Window_Up = 0.9; Window_Down = 0.6; Window_P = 0.1; Window_H = 0.1; C[1] = x[1] - a[1]; C[2] = x[2] - a[2]; C[3] = x[3] - a[3]; H_Length = a[4]/2; H_Width = a[5]/2; H_Height = a[6]/2; Window_1 = (C[1]-(-H_Length+a[4]*Cabin_D*Window_P)) & (-H_Length + a[4]*Cabin_D*(1-Window_P) - C[1]) & (C[2]-(-H_Height+a[6]*Window_Down)) & (-H_Height+a[6]*Window_Up - C[2]); Window_2 = (C[3]-(-H_Width + a[5]*Window_H)) & (-a[5]*Window_H-C[3]) & (C[2]-(-H_Height+a[6]*Window_Down)) & (-H_Height+a[6]*Window_Up - C[2]) & (C[1]+H_Length) & (-H_Length + a[4]*Cabin_D - C[1]); Window_3 = (C[3]-a[5]*Window_H) & (H_Width - a[5]*Window_H-C[3]) & (C[2]-(-H_Height+a[6]*Window_Down)) & (-H_Height+a[6]*Window_Up - C[2]) & (C[1]+H_Length) & (-H_Length + a[4]*Cabin_D - C[1]); Cabin = (C[1]+H_Length) & (-H_Length + a[4]*Cabin_D - C[1]) & (C[2]+H_Height) & (H_Height-C[2]) & (C[3]+H_Width) & (H_Width-C[3]); Body = (C[1]+H_Length) & (H_Length-C[1]) & ((C[3]-(-H_Width+Window_P*a[5])) & (H_Width-Window_P*a[5]-C[3]) & (C[2]-(-H_Height)) & (-H_Height + a[6]*Window_P-C[2]) | (1 - sqrt( ((C[2] + (H_Height-a[6]*Window_P)/2)/((H_Height-a[6]*Window_P)/2))^2+(C[3]/(H_Width-Window_P*a[5]))^2 ))); Pipe = (H_Height-H_Height*Cabin_D/2-C[2]) & ((C[2]+H_Height)/4 - sqrt((C[1]-(H_Length-a[4]*Cabin_D/2))^2 + C[3]^2)); Radius = a[4]/10; i = 1; while(i<4) loop Wheel_Array[1] = -H_Length + Radius*2 + (a[4]*0.3)*(i-1); Wheel_Array[2] = -H_Height - Radius*1.5; Wheel_Array[3] = -H_Width; Wheel_Array[4] = Radius; -- Radius Wheel_Array[5] = a[5]/5; Wheel[i] = Cyl_z(C, Wheel_Array); Wheel_Array[3] = H_Width; Wheel[i] = Wheel[i] | Cyl_z(C, Wheel_Array); i = i + 1; endloop; Steam_Machine_x = (Cabin | Body | Pipe | Wheel[1] | Wheel[2] | Wheel[3]) \ Window_1 \ Window_2 \ Window_3; } Railway_and_SteamMachine(X[3], A[1]) { array For_SM[6]; array For_RW[9]; For_SM[1] = 0; For_SM[2] = 0; For_SM[3] = 0; For_SM[4] = 12.0; For_SM[5] = 6.0; For_SM[6] = 8.0; For_RW[1] = 0.0; For_RW[2] = -8.2; For_RW[3] = 0.0; For_RW[4] = 14.0; For_RW[5] = 8.0; For_RW[6] = 6.0; For_RW[7] = 5; For_RW[8] = 0.5; For_RW[9] = 0.3; -- a[4] - railway length -- a[5] - railway width -- a[6] - rut width -- a[7] - amount of sleeper -- a[8] - radius of sleeper -- a[9] - radius of rail Railway_and_SteamMachine = Steam_Machine_x(x, For_SM) | railway_xz(x, For_RW); }