Tutorial: Automatic design of ball-bearing link/joint connections and DC motor mounts using the SG-Lib
Prof. Dr. Tim Lueth, TUM, Munich for Prof. Dr. Frank Talke, UCSD, San Diego, May 2022
Design of simple geometries
%The SGofCPLcommand function makes it relatively easy to design and process 2.5D geometries.
SGofCPLcommand('c 5, h 10, b 6, h 4'); SG=ans
SGofCPLcommand: SGofCPLcommand("c 5, h 10, b 6, h 4")
SGofCPLcommand: SGfigureeval('SGofCPLcommand("c 5, h 10, b 6, h 4");');
SG =
VL: [54×3 double]
FL: [100×3 double]
FC: [100×3 double]
There are also some functions for directly creating frequently used shapes such as cuboids.
SGbar([30 20 15]); SG=ans;
Design of simple spatial transformations relative to bodies
The SGtransrelSG function can be used to arrange bodies spatially relative to other bodies. It is also possible to simply specify the homogeneous transformation matrix for these spatial movements.
TofSG(SG,'ontop')
1.0000 0 0 0
0 1.0000 0 0
0 0 1.0000 7.5000
0 0 0 1.0000
TofSG(SG,'right')
0 0 1 15
0 1 0 0
-1 0 0 0
0 0 0 1
TofSG(SG,'front')
1 0 0 0
0 0 -1 -10
0 1 0 0
0 0 0 1
Currently, there are still two different concepts if you only want the matrix.
TofSG2022(SG,'facefront');
TofSG2022(SG,'facefront','alignright',-4,'top',-3); T=ans
1.0000 0 0 11.0000
0 0 -1.0000 -10.0000
0 1.0000 0 4.5000
0 0 0 1.0000
Automatic design of screw connections with screws (DIN912) and nuts (DIN985)
[Hsub,Nsub,SCRW]=SGdesignDIN912DIN985([2 6],'TP',50); % Subtraction solid
SGdesignDIN912DIN985: Creating Nut M2.0
SGdesignDIN912DIN985: Creating Screw M2.0 x 6mm
SGremsurfedgepoints: 15%
Warning: "SGunion(SG,SGA)" FAILED in "SGDIN912"
SGunion: Using "SGconcat(SG,SGA)" instead of "SGunion(SG,SGA)".
SGremsurfedgepoints: 10%FLrepair: (SGsubtract) 1 open triangle(s) closed.
FLrepair: (SGsubtract) No open boundaries finally exist!
SGdesignDIN912DIN985: Creating Head Side Bore 2.0mm x 1.7mm
SGdesignDIN912DIN985: Creating Head Insertion Tunnel 2.0mm x 1.5mm
SGdesignDIN912DIN985: Creating Head Insertion Pocket 3.9mm x 8.1mm x 50mm
SGdesignDIN912DIN985: Creating Nut Side Bore 2.0mm x 4.7mm
SGdesignDIN912DIN985: Creating Nut Insertion Tunnel 4.0mm x 50.0mm
SGdesignDIN912DIN985: Creating Head Insertion Pocket 4.0mm x 3.3mm x 50mm
SGdesignDIN912DIN985: =======================================================
SGremsurfedgepoints: 20% 40%
Warning: "SGunion(,)" FAILED in "SGunion"
SGunion: Using "SGconcat(,)" instead of "SGunion(,)".
SGremsurfedgepoints: 15% 25%
Warning: "SGunion(,)" FAILED in "SGunion"
SGunion: Using "SGconcat(,)" instead of "SGunion(,)".
SGA=SGsubtract(SG,Nsub,'alignT',{'C',T})
FLrepair: (SGremsurfedgepoints) No open boundaries finally exist!
FLrepair: (SGsubtract) No open boundaries finally exist!
SGA =
VL: [50×3 double]
FL: [92×3 double]
FC: [92×3 double]
Tname: {}
T: {}
TFiL: {}
SGB=SGsubtract(SG,Hsub,'alignT',{'C',T})
SGremsurfedgepoints: 10% 20% 30% 40% 50% 60% 70% 80% 90%
SGB =
VL: [120×3 double]
FL: [236×3 double]
FC: [236×3 double]
Tname: {}
T: {}
TFiL: {}
SGplotalpha(SCRW,'r',1,'',SG,'matchT',{'C',T});
SGplotalpha(SGB,'y',1,'',SG,'alignT',{T,T});
shg; view(0,-90); VLFLplotlight(1,0.5);
Automatic design with insertbushings (Kerbkonus) and screws (DIN912)
[Hsub,Nsub,SCRW]=SGdesignDIN912BushingE([2 6],'TT',50); % Subtraction solid
SGdesignDIN912BushingE: Creating Bushing M2.0
SGremsurfedgepoints: 15%
Warning: "SGunion(SG,SGA)" FAILED in "SGDIN912"
SGunion: Using "SGconcat(SG,SGA)" instead of "SGunion(SG,SGA)".
SGremsurfedgepoints: 10%FLrepair: (SGsubtract) 1 open triangle(s) closed.
FLrepair: (SGsubtract) No open boundaries finally exist!
FLrepair: (SGremsurfedgepoints) No open boundaries finally exist!
FLrepair: (SGunion) No open boundaries finally exist!
SGA=SGsubtract(SG,Nsub,'alignT',{'C',T})
FLrepair: (SGremsurfedgepoints) No open boundaries finally exist!
FLrepair: (SGsubtract) No open boundaries finally exist!
SGA =
VL: [46×3 double]
FL: [84×3 double]
FC: [84×3 double]
Tname: {}
T: {}
TFiL: {}
SGB=SGsubtract(SG,Hsub,'alignT',{'C',T})
SGboolh: Solid B is not watertight
SGboolh: "SGboolh('-','A','B')" called during "SGsubtract" failed: Solid A is unchanged
Warning: "SGsubtract(SG,Hsub)" FAILED in "LiveEditorEvaluationHelperE1641513619"
SGB =
VL: [8×3 double]
FL: [12×3 double]
Tname: {}
T: {}
TFiL: {}
SGplotalpha(SCRW,'r',1,'',SG,'matchT',{'C',T});
SGplotalpha(SGB,'y',1,'',SG,'alignT',{T,T});
shg; view(0,-90); VLFLplotlight(1,0.5);
Automatic design for screws with self-tapping threads (DIN7991)
[Hsub,Nsub,SCRW]=SGdesignDIN7991 ([2 6],'TT',50); % Subtraction solid
SGremsurfedgepoints: 20% 40% 60% 80%
Warning: "SGunion(A,C)" FAILED in "SGDIN7991head"
SGunion: Using "SGconcat(A,C)" instead of "SGunion(A,C)".
SGbool: Grid resolution 0.1µ. Number of reduced vertices is A: 21 and for B:0
SGboolh: "SGboolh('-','A','B')" called during "SGsubtract" failed: Solid A is unchanged
Warning: "SGsubtract(A,B)" FAILED in "SGDIN7991head"
SGA=SGsubtract(SG,Nsub,'alignT',{'C',T})
FLrepair: (SGremsurfedgepoints) No open boundaries finally exist!
FLrepair: (SGsubtract) No open boundaries finally exist!
SGA =
VL: [50×3 double]
FL: [96×3 double]
FC: [96×3 double]
Tname: {}
T: {}
TFiL: {}
SGB=SGsubtract(SG,Hsub,'alignT',{'C',T})
FLrepair: (SGremsurfedgepoints) No open boundaries finally exist!
FLrepair: (SGsubtract) No open boundaries finally exist!
SGB =
VL: [92×3 double]
FL: [176×3 double]
FC: [176×3 double]
Tname: {}
T: {}
TFiL: {}
SGplotalpha(SCRW,'r',1,'',SG,'matchT',{'C',T});
SGplotalpha(SGB,'y',1,'',SG,'alignT',{T,T});
shg; view(0,-90); VLFLplotlight(1,0.5);
Automatic design for Screw connections (DIN912/DIN985) with radial ball bearings
[Hsub,Nsub,SCRW]=SGdesignDIN912DIN985radialbearing([1.6 4 1.8],[6],'TT',50); % Subtraction solid
SGdesignDIN912DIN985radialbearing: Creating Nut M1.6
DINfindinTab: No exact entry found for 1.6 in DIN_985 ==> 2.0 returned instead!
SGdesignDIN912DIN985radialbearing: Creating Screw M1.60 x 6mm
SGremsurfedgepoints: 15%
Warning: "SGunion(SG,SGA)" FAILED in "SGDIN912"
SGunion: Using "SGconcat(SG,SGA)" instead of "SGunion(SG,SGA)".
SGremsurfedgepoints: 5%SGdesignDIN912DIN985radialbearing: Number of DIN433 washers for a minimal wall size 1.0mm is n=4
SGdesignDIN912DIN985radialbearing: The exact wall size on bearing size is: 1.1mm. The thread length on bearing side is 2.9mm
SGdesignDIN912DIN985radialbearing: Creating Head Side Bore 1.8mm x 1.3mm
SGdesignDIN912DIN985radialbearing: Creating Bearing Insertion Tunnel 1.60mm x 4.00mm
SGdesignDIN912DIN985radialbearing: Creating Head Insertion Pocket 3.1mm x 7.7mm x 50mm
SGdesignDIN912DIN985radialbearing: Creating Nut Side Bore 1.6mm x 3.3mm
SGdesignDIN912DIN985radialbearing: Creating Nut Insertion Tunnel 4.0mm x 50.0mm
SGdesignDIN912DIN985radialbearing: Creating Head Insertion Pocket 4.0mm x 3.1mm x 50mm
SGdesignDIN912DIN985radialbearing: =======================================================
SGremsurfedgepoints: 20% 40%
Warning: "SGunion(,)" FAILED in "SGunion"
SGunion: Using "SGconcat(,)" instead of "SGunion(,)".
SGremsurfedgepoints: 10% 20%
Warning: "SGunion(,)" FAILED in "SGunion"
SGunion: Using "SGconcat(,)" instead of "SGunion(,)".
SGA=SGsubtract(SG,Nsub,'alignT',{'C',T})
FLrepair: (SGremsurfedgepoints) 8 open triangle(s) closed.
FLrepair: (SGremsurfedgepoints) No open boundaries finally exist!
FLrepair: (SGsubtract) No open boundaries finally exist!
SGA =
VL: [65×3 double]
FL: [133×3 double]
FC: [133×3 double]
Tname: {}
T: {}
TFiL: {}
SGB=SGsubtract(SG,Hsub,'alignT',{'C',T})
SGremsurfedgepoints: 10% 20% 30% 40% 50% 60% 70% 80% 90%
SGB =
VL: [138×3 double]
FL: [272×3 double]
FC: [272×3 double]
Tname: {}
T: {}
TFiL: {}
SGplotalpha(SCRW,'r',1,'',SG,'matchT',{'C',T});
SGplotalpha(SGB,'y',1,'',SG,'alignT',{T,T});
shg; view(0,-90); VLFLplotlight(1,0.5);
Automatic design for Screw connections (DIN912/DIN985) with axial ball bearings
[Hsub,Nsub,SCRW]=SGdesignDIN912DIN985axialbearing([1.6 11 1.8],'TT',50,'','',[1.6 4 1.8 1.4 1.6]); % Subtraction solid
SGdesignDIN912DIN985axialbearing: Creating Nut M1.6
DINfindinTab: No exact entry found for 1.6 in DIN_985 ==> 2.0 returned instead!
SGdesignDIN912DIN985axialbearing: Creating Screw M1.60 x 11mm
SGboolh: Solid A is not watertight
SGremsurfedgepoints: 15%
Warning: "SGunion(SG,SGA)" FAILED in "SGDIN912"
SGunion: Using "SGconcat(SG,SGA)" instead of "SGunion(SG,SGA)".
SGboolh: Solid A is not watertight
SGremsurfedgepoints: 5%FLrepair: (SGsubtract) 1 open triangle(s) closed.
FLrepair: (SGsubtract) No open boundaries finally exist!
SGdesignDIN912DIN985axialbearing: Creating Walls of 1.3mm
SGdesignDIN912DIN985axialbearing: Creating Head Side Bore 1.6mm x 3.3mm
SGdesignDIN912DIN985axialbearing: Creating Head Insertion Tunnel 1.6mm x 3.1mm
SGdesignDIN912DIN985axialbearing: Creating Head Insertion Pocket 3.1mm x 12.7mm x 50mm
SGdesignDIN912DIN985axialbearing: Creating Nut Side Bore 1.6mm x 8.1mm
SGdesignDIN912DIN985axialbearing: Creating Nut Insertion Tunnel 4.0mm x 50.0mm
SGdesignDIN912DIN985axialbearing: Creating Head Insertion Pocket 4.0mm x 3.1mm x 50mm
SGdesignDIN912DIN985axialbearing: =======================================================
SGremsurfedgepoints: 10% 20% 35% 45% 55% 65%
Warning: "SGunion(,)" FAILED in "SGunion"
SGunion: Using "SGconcat(,)" instead of "SGunion(,)".
SGremsurfedgepoints: 5% 15%
Warning: "SGunion(,)" FAILED in "SGunion"
SGunion: Using "SGconcat(,)" instead of "SGunion(,)".
SGA=SGsubtract(SG,Nsub,'alignT',{'C',T})
SGremsurfedgepoints: 5% 10% 20% 25% 30% 35% 40% 45% 55% 60% 65%
SGA =
VL: [157×3 double]
FL: [310×3 double]
FC: [310×3 double]
Tname: {}
T: {}
TFiL: {}
SGB=SGsubtract(SG,Hsub,'alignT',{'C',T})
SGremsurfedgepoints: 10% 15% 25% 35% 40% 50% 60% 65%
SGB =
VL: [189×3 double]
FL: [374×3 double]
FC: [374×3 double]
Tname: {}
T: {}
TFiL: {}
SGplotalpha(SCRW,'r',1,'',SG,'matchT',{'C',T});
SGplotalpha(SGB,'y',1,'',SG,'alignT',{T,T});
shg; view(0,-90); VLFLplotlight(1,0.5);
Automatic design for screw connections (DIN912/DIN985) with axial ball bearings and radial ball bearings
[Hsub,Nsub,SCRW]=SGdesignDIN912DIN985axradbearing([2.5 10 -1],'TT',40);
SGdesignDIN912DIN985axradbearing: Creating Nut M2.5
SGdesignDIN912DIN985axradbearing: Creating Screw M2.50 x 10mm
SGremsurfedgepoints: 15%
Warning: "SGunion(SG,SGA)" FAILED in "SGDIN912"
SGunion: Using "SGconcat(SG,SGA)" instead of "SGunion(SG,SGA)".
SGremsurfedgepoints: 5%SGremsurfedgepoints: 20% 40%
Warning: "SGunion(SBR1,SBR2)" FAILED in "SGdesignDIN912DIN985axradbearing"
SGunion: Using "SGconcat(SBR1,SBR2)" instead of "SGunion(SBR1,SBR2)".
SGdesignDIN912DIN985axradbearing: Creating Walls of 1.1mm
SGdesignDIN912DIN985axradbearing: Creating Head Side Bore 2.5mm x 1.3mm
SGdesignDIN912DIN985axradbearing: Creating Head Insertion Tunnel 2.5mm x 1.1mm
SGremsurfedgepoints: 10% 15%
Warning: "SGunion(HSB,SBR)" FAILED in "SGdesignDIN912DIN985axradbearing"
SGunion: Using "SGconcat(HSB,SBR)" instead of "SGunion(HSB,SBR)".
SGdesignDIN912DIN985axradbearing: Creating Head Insertion Pocket 4.6mm x 12.6mm x 40mm
SGdesignDIN912DIN985axradbearing: Creating Nut Side Bore 2.5mm x 9.1mm
SGdesignDIN912DIN985axradbearing: Creating Nut Insertion Tunnel 5.0mm x 40.0mm
SGdesignDIN912DIN985axradbearing: Creating Head Insertion Pocket 5.0mm x 3.6mm x 40mm
SGdesignDIN912DIN985axradbearing: =======================================================
SGremsurfedgepoints: 5% 15% 20%
Warning: "SGunion(,)" FAILED in "SGunion"
SGunion: Using "SGconcat(,)" instead of "SGunion(,)".
SGremsurfedgepoints: 5% 15%
Warning: "SGunion(,)" FAILED in "SGunion"
SGunion: Using "SGconcat(,)" instead of "SGunion(,)".
SGA=SGsubtract(SG,Nsub,'alignT',{'C',T})
SGremsurfedgepoints: 5% 10% 20% 25% 30% 35% 40% 45% 55% 60% 65%
SGA =
VL: [179×3 double]
FL: [354×3 double]
FC: [354×3 double]
Tname: {}
T: {}
TFiL: {}
SGB=SGsubtract(SG,Hsub,'alignT',{'C',T})
SGbool: Grid resolution 0.1µ. Number of reduced vertices is A: 0 and for B:212
SGboolh: "SGboolh('-','A','B')" called during "SGsubtract" failed: Solid A is unchanged
Warning: "SGsubtract(SG,Hsub)" FAILED in "LiveEditorEvaluationHelperE1641513619"
SGB =
VL: [8×3 double]
FL: [12×3 double]
Tname: {}
T: {}
TFiL: {}
SGplotalpha(SCRW,'r',1,'',SG,'matchT',{'C',T});
SGplotalpha(SGB,'y',1,'',SG,'alignT',{T,T});
shg; view(0,-90); VLFLplotlight(1,0.5);
Relative spatial arrangement of bodies for automatic design
SGbar([30 20 15]); SG=ans;
TofSG2022(SG,'facetop'); T=ans
1.0000 0 0 0
0 1.0000 0 0
0 0 1.0000 7.5000
0 0 0 1.0000
SGB=SGTset(SG,'B',T); % SGB=SGTsetorigin(SGB,'B',T);
SGfigure (-30,30); SGTplotalpha(SGA,'g',0.5); SGTplotalpha(SGB,'y','','',SGA,'alignT',{'B','F',pi/2});
Automatic design of a motor mount for an electric motor (model N40)
[Hsub,Nsub,N40]=SGdesignMotorN40horiz;
SGremsurfedgepoints: 5% 10% 15% 20% 25% 30% 35% 40% 45% 50%SGremsurfedgepoints: 5% 10% 15% 20% 25% 30% 35% 40% 45% 50% 55% 60% 65% 70% 75% 80%
Warning: Edge constraints have been split by a coincident point.
85%FLrepair: (SGremsurfedgepoints) No open boundaries finally exist!
FLrepair: (SGunion) No open boundaries finally exist!
SGremsurfedgepoints: 5% 10% 15% 20% 25% 30% 35% 40% 45% 50% 55% 60% 65%
Warning: "SGunion(A,C)" FAILED in "SGDIN7991head"
SGunion: Using "SGconcat(A,C)" instead of "SGunion(A,C)".
SGbool: Grid resolution 0.1µ. Number of reduced vertices is A: 1 and for B:0
SGboolh: "SGboolh('-','A','B')" called during "SGsubtract" failed: Solid A is unchanged
Warning: "SGsubtract(A,B)" FAILED in "SGDIN7991head"
SGboolh: Solid A is not watertight
FLrepair: (SGremsurfedgepoints) No open boundaries finally exist!
FLrepair: (SGunion) No open boundaries finally exist!
SGboolh: Solid A is not watertight
SGremsurfedgepoints: 5% 10% 15% 20% 25% 30% 35% 40% 45% 50% 55% 60% 65% 70% 75% 80% 85% 90%
Warning: "SGunion(SGA,SGADD)" FAILED in "SGsubtractnaddTL"
SGunion: Using "SGconcat(SGA,SGADD)" instead of "SGunion(SGA,SGADD)".
SGboolh: Solid B is not watertight
SGboolh: "SGboolh('-','A','B')" called during "SGsubtract" failed: Solid A is unchanged
Warning: "SGsubtract(A,Nsub)" FAILED in "SGdesignMotorN40horiz"
SGremsurfedgepoints: 10% 20% 30% 40% 50% 60% 70% 80% 90%
Warning: "SGunion(B,Hadd)" FAILED in "SGdesignMotorN40horiz"
SGunion: Using "SGconcat(B,Hadd)" instead of "SGunion(B,Hadd)".
SGremsurfedgepoints: 5% 10%FLrepair: (SGsubtract) 2 open triangle(s) closed.
FLrepair: (SGsubtract) No open boundaries finally exist!
SGfigure; SGTplotalpha(SGA);
SGsubtract(SGA,Nsub,'alignT',{'C','F',TofP([0 0 -d])})
SGboolh: Solid B is not watertight
SGboolh: "SGboolh('-','A','B')" called during "SGsubtract" failed: Solid A is unchanged
Warning: "SGsubtract(SGA,Nsub)" FAILED in "LiveEditorEvaluationHelperE1641513619"
ans =
VL: [8×3 double]
FL: [12×3 double]
Tname: {'F'}
T: {[4×4 double]}
TFiL: {[]}
SGplotalpha(N40,'m','','',SGA,'alignT',{'C','F',TofP([0 0 +d])});
stamp
stamp: Mac OSX 15.6 | R2024b Update 6 | SG-Lib 5.4 | Java 1.8.0_202-b08 | i7-Intelx64 6-Core 64GByte RAM | 05-Aug-2025 21:51:02