Skip to main content

Tangent lines and circles

Many outlines are built from pieces that touch: a belt around two pulleys, a slot rounded into a plate, an arc that joins two lines smoothly. OpenCascade can work out where such pieces go. You give it the curves to touch and the plane to work in, and it gives back every line or circle that fits.

The constructions​

FunctionGives every
linesTangentToTwostraight line that touches two curved edges, or touches one and passes through a point
linesTangentAtAnglestraight line that touches a curved edge at an angle to a straight reference edge
circlesTangentToTwoWithRadiuscircle of a given radius that touches two edges, or passes through the points among them
circlesTangentToTwoCenteredOncircle centred on one edge that touches two others
circlesTangentToThreecircle that touches three edges, or passes through the points among them

All five live under bitbybit.occt.shapes.edge, and work the same way:

  • The shapes are edges, or vertices for points (bitbybit.occt.shapes.vertex.vertexFromPoint makes one from [x, y, z]).
  • The frame gives the plane they lie in: its origin is a point on the plane and its normal is square to it. bitbybit.frame.zx is the ground; bitbybit.frame.xy stands upright.
  • Every solution comes back, as a list of edges. Two circles have up to four lines touching both, and you choose the ones you need from the list.
  • Arcs count as whole circles, and straight edges as endless lines, unless onArgumentsOnly keeps only the solutions that touch within the edges' ends.

A belt between two wheels​

Two circles lie on the ground, and every straight line touching both is drawn: the two outer lines a belt would follow, and the two that cross between the wheels:

Lines tangent to two circles
Bitbybit Platform

Lines tangent to two circles in Rete

rete logoRete
Script Source (rete)
{
"id": "rete-v2-json",
"nodes": {
"big": {
"id": "big",
"name": "bitbybit.occt.shapes.edge.createCircleEdge",
"customName": "circle edge",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 3,
"center": [
-4,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {},
"position": [
40,
40
]
},
"small": {
"id": "small",
"name": "bitbybit.occt.shapes.edge.createCircleEdge",
"customName": "circle edge",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 1.5,
"center": [
4,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {},
"position": [
40,
420
]
},
"wheels": {
"id": "wheels",
"name": "bitbybit.lists.createList",
"customName": "create list",
"async": false,
"drawable": false,
"data": {},
"inputs": {
"listElements": {
"connections": [
{
"node": "big",
"output": "result",
"data": {}
},
{
"node": "small",
"output": "result",
"data": {}
}
]
}
},
"position": [
460,
240
]
},
"ground": {
"id": "ground",
"name": "bitbybit.frame.zx",
"customName": "zx",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"origin": [
0,
0,
0
]
},
"inputs": {},
"position": [
460,
520
]
},
"belt": {
"id": "belt",
"name": "bitbybit.occt.shapes.edge.linesTangentToTwo",
"customName": "lines tangent to two",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"angularTolerance": 0.000001,
"onArgumentsOnly": false
},
"inputs": {
"shapes": {
"connections": [
{
"node": "wheels",
"output": "list",
"data": {}
}
]
},
"frame": {
"connections": [
{
"node": "ground",
"output": "result",
"data": {}
}
]
}
},
"position": [
880,
240
]
}
},
"modules": {}
}

To build the belt itself, take the two outer lines from the list, trim the circles to the arcs between the touch points, and join the four edges into a wire with bitbybit.occt.shapes.wire.combineEdgesAndWiresIntoAWire.

shapes.face.createFaceFromMultipleCircleTanWires draws those belts for you and turns them into a face. Give it circles and with combination set to allWithAll it joins each circle to every other. The triangle left between the three belts stays open, so the outline comes with a lightening window of its own:

A link plate around three pins
Bitbybit Platform

A link plate around three pins in Rete

rete logoRete
Script Source (rete)
{
"id": "rete-v2-json",
"nodes": {
"heelCircle": {
"id": "heelCircle",
"name": "bitbybit.occt.shapes.wire.createCircleWire",
"customName": "circle wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 3.2,
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {},
"position": [
40,
40
]
},
"tipCircle": {
"id": "tipCircle",
"name": "bitbybit.occt.shapes.wire.createCircleWire",
"customName": "circle wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 1.8,
"center": [
13,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {},
"position": [
40,
334
]
},
"crownCircle": {
"id": "crownCircle",
"name": "bitbybit.occt.shapes.wire.createCircleWire",
"customName": "circle wire",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 2.2,
"center": [
5,
0,
10
],
"direction": [
0,
1,
0
]
},
"inputs": {},
"position": [
40,
628
]
},
"heelHole": {
"id": "heelHole",
"name": "bitbybit.occt.shapes.solid.createCylinder",
"customName": "cylinder",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 1.6,
"height": 4,
"center": [
0,
-1,
0
],
"direction": [
0,
1,
0
],
"angle": 360,
"originOnCenter": false
},
"inputs": {},
"position": [
40,
922
]
},
"tipHole": {
"id": "tipHole",
"name": "bitbybit.occt.shapes.solid.createCylinder",
"customName": "cylinder",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 0.9,
"height": 4,
"center": [
13,
-1,
0
],
"direction": [
0,
1,
0
],
"angle": 360,
"originOnCenter": false
},
"inputs": {},
"position": [
40,
1354
]
},
"crownHole": {
"id": "crownHole",
"name": "bitbybit.occt.shapes.solid.createCylinder",
"customName": "cylinder",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 1.1,
"height": 4,
"center": [
5,
-1,
10
],
"direction": [
0,
1,
0
],
"angle": 360,
"originOnCenter": false
},
"inputs": {},
"position": [
40,
1786
]
},
"circles": {
"id": "circles",
"name": "bitbybit.lists.createList",
"customName": "create list",
"async": false,
"drawable": false,
"data": {},
"inputs": {
"listElements": {
"connections": [
{
"node": "heelCircle",
"output": "result",
"data": {}
},
{
"node": "tipCircle",
"output": "result",
"data": {}
},
{
"node": "crownCircle",
"output": "result",
"data": {}
}
]
}
},
"position": [
460,
40
]
},
"outline": {
"id": "outline",
"name": "bitbybit.occt.shapes.face.createFaceFromMultipleCircleTanWires",
"customName": "face from multiple circle tan wires",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"combination": "allWithAll",
"unify": true,
"tolerance": 1e-7
},
"inputs": {
"circles": {
"connections": [
{
"node": "circles",
"output": "list",
"data": {}
}
]
}
},
"position": [
880,
40
]
},
"blank": {
"id": "blank",
"name": "bitbybit.occt.operations.extrude",
"customName": "extrude",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"direction": [
0,
1.2,
0
]
},
"inputs": {
"shape": {
"connections": [
{
"node": "outline",
"output": "result",
"data": {}
}
]
}
},
"position": [
1300,
40
]
},
"holes": {
"id": "holes",
"name": "bitbybit.lists.createList",
"customName": "create list",
"async": false,
"drawable": false,
"data": {},
"inputs": {
"listElements": {
"connections": [
{
"node": "heelHole",
"output": "result",
"data": {}
},
{
"node": "tipHole",
"output": "result",
"data": {}
},
{
"node": "crownHole",
"output": "result",
"data": {}
}
]
}
},
"position": [
460,
280
]
},
"plate": {
"id": "plate",
"name": "bitbybit.occt.booleans.difference",
"customName": "difference",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"keepEdges": false,
"strategy": "oneAfterAnother"
},
"inputs": {
"shape": {
"connections": [
{
"node": "blank",
"output": "result",
"data": {}
}
]
},
"shapes": {
"connections": [
{
"node": "holes",
"output": "list",
"data": {}
}
]
}
},
"position": [
1720,
40
]
},
"steel": {
"id": "steel",
"name": "bitbybit.draw.optionsOcctShape",
"customName": "options occt shape",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"faceOpacity": 1,
"edgeOpacity": 1,
"edgeColour": "#5f6773",
"faceColour": "#ff0000",
"vertexColour": "#ff00ff",
"edgeWidth": 2,
"edgeWidthBySize": false,
"vertexSize": 0.03,
"drawEdges": true,
"drawFaces": true,
"drawVertices": false,
"precision": 0.01,
"angularDeflection": 0.5,
"relativeDeflection": false,
"precisionShare": 0,
"drawEdgeIndexes": false,
"edgeIndexHeight": 0.06,
"edgeIndexColour": "#ff00ff",
"drawFaceIndexes": false,
"faceIndexHeight": 0.06,
"faceIndexColour": "#0000ff",
"drawTwoSided": false,
"backFaceColour": "#0000ff",
"backFaceOpacity": 1,
"edgeArrowSize": 0,
"edgeArrowAngle": 15,
"keepMeshData": false,
"allowQualityDecrease": true,
"forceFaceDeflection": false,
"drawIsoCurves": false,
"isoCurvesU": 5,
"isoCurvesV": 5,
"isoCurvesColour": "#808080",
"surfaceAnalysis": "none",
"draftDirection": [
0,
1,
0
]
},
"inputs": {
"faceMaterial": {
"connections": [
{
"node": "steelMaterial",
"output": "result",
"data": {}
}
]
}
},
"position": [
460,
520
]
},
"steelMaterial": {
"id": "steelMaterial",
"name": "bitbybit.draw.createPBRMaterial",
"customName": "create pbr material",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"name": "PBRMaterial",
"baseColor": "#eef0f2",
"metallic": 0.7,
"roughness": 0.3,
"alpha": 1,
"emissiveColor": "#000000",
"emissiveIntensity": 1,
"zOffset": 0,
"zOffsetUnits": 0,
"alphaMode": "opaque",
"alphaCutoff": 0.5,
"doubleSided": false,
"wireframe": false,
"unlit": false
},
"inputs": {},
"position": [
40,
2218
]
},
"drawPlate": {
"id": "drawPlate",
"name": "bitbybit.draw.drawAnyAsync",
"customName": "draw any async",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
}
},
"inputs": {
"entity": {
"connections": [
{
"node": "plate",
"output": "result",
"data": {}
}
]
},
"options": {
"connections": [
{
"node": "steel",
"output": "result",
"data": {}
}
]
}
},
"position": [
2140,
40
]
},
"view": {
"id": "view",
"name": "bitbybit.babylon.scene.adjustActiveArcRotateCamera",
"customName": "adjust active arc rotate camera",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"position": [
10,
26,
-20
],
"lookAt": [
5.5,
0,
4.5
],
"lowerBetaLimit": 1,
"upperBetaLimit": 179,
"angularSensibilityX": 1000,
"angularSensibilityY": 1000,
"maxZ": 1000,
"panningSensibility": 1000,
"wheelPrecision": 3
},
"inputs": {},
"position": [
2140,
334
]
}
},
"modules": {}
}

Every circle touching three circles​

circlesTangentToThree finds every circle that touches three edges or points. Three circles have eight such circles, some wrapping around them and some tucked between them. It works in the plane of the frame you give it:

Every circle touching three circles
Bitbybit Platform

Every circle touching three circles in Rete

rete logoRete
Script Source (rete)
{
"id": "rete-v2-json",
"nodes": {
"first": {
"id": "first",
"name": "bitbybit.occt.shapes.edge.createCircleEdge",
"customName": "circle edge",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 3,
"center": [
0,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {},
"position": [
40,
40
]
},
"second": {
"id": "second",
"name": "bitbybit.occt.shapes.edge.createCircleEdge",
"customName": "circle edge",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 2,
"center": [
10,
0,
0
],
"direction": [
0,
1,
0
]
},
"inputs": {},
"position": [
40,
334
]
},
"third": {
"id": "third",
"name": "bitbybit.occt.shapes.edge.createCircleEdge",
"customName": "circle edge",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"radius": 2.5,
"center": [
5,
0,
9
],
"direction": [
0,
1,
0
]
},
"inputs": {},
"position": [
40,
628
]
},
"circles": {
"id": "circles",
"name": "bitbybit.lists.createList",
"customName": "create list",
"async": false,
"drawable": false,
"data": {},
"inputs": {
"listElements": {
"connections": [
{
"node": "first",
"output": "result",
"data": {}
},
{
"node": "second",
"output": "result",
"data": {}
},
{
"node": "third",
"output": "result",
"data": {}
}
]
}
},
"position": [
460,
40
]
},
"flat": {
"id": "flat",
"name": "bitbybit.frame.create",
"customName": "frame",
"async": false,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"origin": [
0,
0,
0
],
"normal": [
0,
1,
0
],
"direction": [
1,
0,
0
]
},
"inputs": {},
"position": [
40,
922
]
},
"touching": {
"id": "touching",
"name": "bitbybit.occt.shapes.edge.circlesTangentToThree",
"customName": "circles tangent to three",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": true,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"tolerance": 1e-7,
"onArgumentsOnly": false
},
"inputs": {
"shapes": {
"connections": [
{
"node": "circles",
"output": "list",
"data": {}
}
]
},
"frame": {
"connections": [
{
"node": "flat",
"output": "result",
"data": {}
}
]
}
},
"position": [
880,
40
]
},
"given": {
"id": "given",
"name": "bitbybit.draw.optionsOcctShape",
"customName": "options occt shape",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"faceOpacity": 1,
"edgeOpacity": 1,
"edgeColour": "#ff9f1c",
"faceColour": "#ff0000",
"vertexColour": "#ff00ff",
"edgeWidth": 5,
"edgeWidthBySize": false,
"vertexSize": 0.03,
"drawEdges": true,
"drawFaces": true,
"drawVertices": false,
"precision": 0.01,
"angularDeflection": 0.5,
"relativeDeflection": false,
"precisionShare": 0,
"drawEdgeIndexes": false,
"edgeIndexHeight": 0.06,
"edgeIndexColour": "#ff00ff",
"drawFaceIndexes": false,
"faceIndexHeight": 0.06,
"faceIndexColour": "#0000ff",
"drawTwoSided": true,
"backFaceColour": "#0000ff",
"backFaceOpacity": 1,
"edgeArrowSize": 0,
"edgeArrowAngle": 15,
"keepMeshData": false,
"allowQualityDecrease": true,
"forceFaceDeflection": false,
"drawIsoCurves": false,
"isoCurvesU": 5,
"isoCurvesV": 5,
"isoCurvesColour": "#808080",
"surfaceAnalysis": "none",
"draftDirection": [
0,
1,
0
]
},
"inputs": {},
"position": [
40,
1216
]
},
"found": {
"id": "found",
"name": "bitbybit.draw.optionsOcctShape",
"customName": "options occt shape",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"faceOpacity": 1,
"edgeOpacity": 1,
"edgeColour": "#4fb3ff",
"faceColour": "#ff0000",
"vertexColour": "#ff00ff",
"edgeWidth": 2,
"edgeWidthBySize": false,
"vertexSize": 0.03,
"drawEdges": true,
"drawFaces": true,
"drawVertices": false,
"precision": 0.01,
"angularDeflection": 0.5,
"relativeDeflection": false,
"precisionShare": 0,
"drawEdgeIndexes": false,
"edgeIndexHeight": 0.06,
"edgeIndexColour": "#ff00ff",
"drawFaceIndexes": false,
"faceIndexHeight": 0.06,
"faceIndexColour": "#0000ff",
"drawTwoSided": true,
"backFaceColour": "#0000ff",
"backFaceOpacity": 1,
"edgeArrowSize": 0,
"edgeArrowAngle": 15,
"keepMeshData": false,
"allowQualityDecrease": true,
"forceFaceDeflection": false,
"drawIsoCurves": false,
"isoCurvesU": 5,
"isoCurvesV": 5,
"isoCurvesColour": "#808080",
"surfaceAnalysis": "none",
"draftDirection": [
0,
1,
0
]
},
"inputs": {},
"position": [
40,
3120
]
},
"drawGiven": {
"id": "drawGiven",
"name": "bitbybit.draw.drawAnyAsync",
"customName": "draw any async",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
}
},
"inputs": {
"entity": {
"connections": [
{
"node": "circles",
"output": "list",
"data": {}
}
]
},
"options": {
"connections": [
{
"node": "given",
"output": "result",
"data": {}
}
]
}
},
"position": [
1300,
40
]
},
"drawTouching": {
"id": "drawTouching",
"name": "bitbybit.draw.drawAnyAsync",
"customName": "draw any async",
"async": true,
"drawable": true,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
}
},
"inputs": {
"entity": {
"connections": [
{
"node": "touching",
"output": "result",
"data": {}
}
]
},
"options": {
"connections": [
{
"node": "found",
"output": "result",
"data": {}
}
]
}
},
"position": [
1300,
340
]
},
"view": {
"id": "view",
"name": "bitbybit.babylon.scene.adjustActiveArcRotateCamera",
"customName": "adjust active arc rotate camera",
"async": false,
"drawable": false,
"data": {
"genericNodeData": {
"hide": false,
"oneOnOne": false,
"flatten": 0,
"forceExecution": false
},
"position": [
5,
34,
2
],
"lookAt": [
5,
0,
3
],
"lowerBetaLimit": 1,
"upperBetaLimit": 179,
"angularSensibilityX": 1000,
"angularSensibilityY": 1000,
"maxZ": 1000,
"panningSensibility": 1000,
"wheelPrecision": 3
},
"inputs": {},
"position": [
1300,
640
]
}
},
"modules": {}
}

The older constraint functions​

The constraintTan... functions of earlier versions, such as constraintTanLinesOnTwoCircles, still work, but are deprecated and will be removed in a future major version. Each has a counterpart above, which takes a frame instead of assuming the ground and gives every solution.