Skip to content

Latest commit

 

History

History
214 lines (170 loc) · 48.5 KB

File metadata and controls

214 lines (170 loc) · 48.5 KB
sidebar_position 4
title Edge Constraints
sidebar_label Edge Constraints
description Learn
tags
occt

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import BitByBitRenderCanvas from '@site/src/components/BitByBitRenderCanvas';

Edge Constraints

OCCT category icon with a stylized logo representation

Edge constraints in OCCT (Open CASCADE Technology) provide powerful geometric constraint solving capabilities for creating tangent lines and circles based on existing geometric entities. These operations are essential for parametric modeling, geometric construction, and constraint-based design workflows.

Overview

Edge constraints help you create geometry that follows specific rules or relationships with existing shapes. Think of them as intelligent drawing tools that automatically calculate where new lines or circles should be placed to maintain tangent relationships with your existing geometry.

The system offers five main constraint operations that solve common geometric problems. You can create tangent lines between points and circles, tangent lines between two circles, and even tangent circles that touch existing circles or points. Each operation automatically calculates the mathematically correct positions and orientations.

Understanding the Examples

Each constraint operation is demonstrated using three different programming approaches. The Rete interface lets you build constraint solutions visually by connecting nodes. Blockly provides a block-based approach that's great for learning the logical flow. TypeScript gives you direct code control for advanced customization and integration into larger projects.

All examples use similar patterns - they create the base geometry (circles and points), set up the constraint parameters, execute the constraint operation, and then display the results. The constraint functions handle all the complex mathematical calculations automatically.

Working with Tolerance and Precision

Most constraint operations include a tolerance setting that controls how precisely the calculations are performed. The default value works well for most situations, but you might need to adjust it when working with very large or very small geometry. Think of tolerance as how "strict" the geometric relationships need to be.

Constraint Tangent Lines from Two Points to Circle

This operation solves a classic geometric problem: given two points and a circle, find the lines that connect both points and are tangent to the circle. The function automatically calculates all possible solutions and returns the tangent lines.

This is particularly useful in mechanical design when you need to connect two specific locations with smooth curves that don't intersect existing circular features.

circlepoint1point2tangentLinescircle4000010point1007point2909tangentLinescirclepoint1point21e-7'all''none'tangentLinescirclepoint1point2","version":"0.20.7","type":"blockly"}} title="Constraint tangent lines from two points to circle" /> {\n // Create a circle edge\n const circleOptions = new CircleDto();\n circleOptions.radius = 4;\n circleOptions.center = [0, 0, 0] as Point3;\n circleOptions.direction = [0, 1, 0] as Vector3;\n\n const circle = await bitbybit.occt.shapes.edge.createCircleEdge(circleOptions);\n\n // Define two points\n const point1: Point3 = [0, 0, 7];\n const point2: Point3 = [9, 0, 9];\n\n // Create constraint options for tangent lines from two points to circle\n const constraintOptions = new ConstraintTanLinesFromTwoPtsToCircleDto();\n constraintOptions.circle = circle;\n constraintOptions.point1 = point1;\n constraintOptions.point2 = point2;\n constraintOptions.tolerance = 1e-7;\n constraintOptions.positionResult = positionResultEnum.all;\n constraintOptions.circleRemainder = circleInclusionEnum.none;\n\n // Create the constraint tangent lines\n const tangentLines = await bitbybit.occt.shapes.edge.constraintTanLinesFromTwoPtsToCircle(constraintOptions);\n\n // Draw the tangent lines\n bitbybit.draw.drawAnyAsync({ entity: tangentLines });\n // Draw the circle\n bitbybit.draw.drawAnyAsync({ entity: circle });\n // Draw the two points\n bitbybit.draw.drawAnyAsync({ entity: [point1] });\n bitbybit.draw.drawAnyAsync({ entity: [point2] });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} title="Constraint tangent lines from two points to circle" />

Constraint Tangent Lines from Point to Circle

When you need to draw lines from a single point that just touch a circle without crossing it, this constraint operation provides the solution. It's simpler than the two-point version and automatically finds both possible tangent lines from your point to the circle.

This operation is commonly used in architectural drawings when you need to create sight lines or in mechanical design for clearance calculations.

circlepointtangentLinescircle4000010point807tangentLinescirclepoint1e-7'all''none'tangentLinescirclepoint","version":"0.20.7","type":"blockly"}} title="Constraint tangent lines from point to circle" /> {\n // Create a circle edge\n const circleOptions = new CircleDto();\n circleOptions.radius = 4;\n circleOptions.center = [0, 0, 0] as Point3;\n circleOptions.direction = [0, 1, 0] as Vector3;\n\n const circle = await bitbybit.occt.shapes.edge.createCircleEdge(circleOptions);\n\n // Define a point\n const point: Point3 = [8, 0, 7];\n\n // Create constraint options for tangent lines from point to circle\n const constraintOptions = new ConstraintTanLinesFromPtToCircleDto();\n constraintOptions.circle = circle;\n constraintOptions.point = point;\n constraintOptions.tolerance = 1e-7;\n constraintOptions.positionResult = positionResultEnum.all;\n constraintOptions.circleRemainder = circleInclusionEnum.none;\n\n // Create the constraint tangent lines\n const tangentLines = await bitbybit.occt.shapes.edge.constraintTanLinesFromPtToCircle(constraintOptions);\n\n // Draw the tangent lines\n bitbybit.draw.drawAnyAsync({ entity: tangentLines });\n // Draw the circle\n bitbybit.draw.drawAnyAsync({ entity: circle });\n // Draw the point\n bitbybit.draw.drawAnyAsync({ entity: point });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} title="Constraint tangent lines from point to circle" />

Constraint Tangent Lines on Two Circles

This operation finds all the lines that touch two circles without crossing them. Depending on how the circles are positioned relative to each other, you might get external tangent lines (that don't pass between the circles) or internal tangent lines (that cross between them).

This is especially valuable in gear design, pulley systems, or any mechanical application where you need smooth transitions between circular components.

circle1circle2tangentLinescircle13000010circle22700010tangentLinescircle1circle21e-7'all''none'tangentLinescircle1circle2","version":"0.20.7","type":"blockly"}} title="Constraint tangent lines on two circles" /> {\n // Create first circle edge\n const circle1Options = new CircleDto();\n circle1Options.radius = 3;\n circle1Options.center = [0, 0, 0] as Point3;\n circle1Options.direction = [0, 1, 0] as Vector3;\n\n const circle1 = await bitbybit.occt.shapes.edge.createCircleEdge(circle1Options);\n\n // Create second circle edge\n const circle2Options = new CircleDto();\n circle2Options.radius = 2;\n circle2Options.center = [7, 0, 0] as Point3;\n circle2Options.direction = [0, 1, 0] as Vector3;\n\n const circle2 = await bitbybit.occt.shapes.edge.createCircleEdge(circle2Options);\n\n // Create constraint options for tangent lines between two circles\n const constraintOptions = new ConstraintTanLinesOnTwoCirclesDto();\n constraintOptions.circle1 = circle1;\n constraintOptions.circle2 = circle2;\n constraintOptions.tolerance = 1e-7;\n constraintOptions.positionResult = positionResultEnum.all;\n constraintOptions.circleRemainders = twoCircleInclusionEnum.none;\n\n // Create the constraint tangent lines\n const tangentLines = await bitbybit.occt.shapes.edge.constraintTanLinesOnTwoCircles(constraintOptions);\n\n // Draw the tangent lines\n bitbybit.draw.drawAnyAsync({ entity: tangentLines });\n // Draw the first circle\n bitbybit.draw.drawAnyAsync({ entity: circle1 });\n // Draw the second circle\n bitbybit.draw.drawAnyAsync({ entity: circle2 });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} title="Constraint tangent lines on two circles" />

Constraint Tangent Circles on Two Circles

Sometimes you need to create circles that touch two existing circles. This operation calculates where to place new circles of a specified size so they're tangent to both input circles. You control the radius of the new circles, and the system figures out all the valid positions.

This is particularly useful for creating buffer zones around existing circular features or for designing complex mechanical linkages where multiple circular components need to interact smoothly.

circle1circle2tangentCirclescircle13000010circle21.5500010tangentCirclescircle1circle21e-70.8tangentCirclescircle1circle2","version":"0.20.7","type":"blockly"}} title="Constraint tangent circles on two circles" /> {\n // Create first circle edge\n const circle1Options = new CircleDto();\n circle1Options.radius = 3;\n circle1Options.center = [0, 0, 0] as Point3;\n circle1Options.direction = [0, 1, 0] as Vector3;\n\n const circle1 = await bitbybit.occt.shapes.edge.createCircleEdge(circle1Options);\n\n // Create second circle edge\n const circle2Options = new CircleDto();\n circle2Options.radius = 1.5;\n circle2Options.center = [5, 0, 0] as Point3;\n circle2Options.direction = [0, 1, 0] as Vector3;\n\n const circle2 = await bitbybit.occt.shapes.edge.createCircleEdge(circle2Options);\n\n // Create constraint options for tangent circles between two circles\n const constraintOptions = new ConstraintTanCirclesOnTwoCirclesDto();\n constraintOptions.circle1 = circle1;\n constraintOptions.circle2 = circle2;\n constraintOptions.tolerance = 1e-7;\n constraintOptions.radius = 0.8;\n\n // Create the constraint tangent circles\n const tangentCircles = await bitbybit.occt.shapes.edge.constraintTanCirclesOnTwoCircles(constraintOptions);\n\n // Draw the tangent circles\n bitbybit.draw.drawAnyAsync({ entity: tangentCircles });\n // Draw the first circle\n bitbybit.draw.drawAnyAsync({ entity: circle1 });\n // Draw the second circle\n bitbybit.draw.drawAnyAsync({ entity: circle2 });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} title="Constraint tangent circles on two circles" />

Constraint Tangent Circles on Circle and Point

This operation creates circles that touch an existing circle and are positioned relative to a specific point. The new circles will be tangent to your input circle and either pass through the point or maintain a specific relationship with it, depending on the radius you specify.

This constraint is perfect for creating rounded transitions in designs where you need a smooth connection between a circular feature and a specific location in your model.

circlepointtangentCirclescircle3000010point400tangentCirclescirclepoint1e-72tangentCirclescirclepoint","version":"0.20.7","type":"blockly"}} title="Constraint tangent circles on circle and point" /> {\n // Create a circle edge\n const circleOptions = new CircleDto();\n circleOptions.radius = 3;\n circleOptions.center = [0, 0, 0] as Point3;\n circleOptions.direction = [0, 1, 0] as Vector3;\n\n const circle = await bitbybit.occt.shapes.edge.createCircleEdge(circleOptions);\n\n // Define a point\n const point: Point3 = [4, 0, 0];\n\n // Create constraint options for tangent circles between circle and point\n const constraintOptions = new ConstraintTanCirclesOnCircleAndPntDto();\n constraintOptions.circle = circle;\n constraintOptions.point = point;\n constraintOptions.tolerance = 1e-7;\n constraintOptions.radius = 2;\n\n // Create the constraint tangent circles\n const tangentCircles = await bitbybit.occt.shapes.edge.constraintTanCirclesOnCircleAndPnt(constraintOptions);\n\n // Draw the tangent circles\n bitbybit.draw.drawAnyAsync({ entity: tangentCircles });\n // Draw the circle\n bitbybit.draw.drawAnyAsync({ entity: circle });\n // Draw the point\n bitbybit.draw.drawAnyAsync({ entity: point });\n}\n\n// Execute the function\nstart();","version":"0.20.7","type":"typescript"}} title="Constraint tangent circles on circle and point" />

Getting the Best Results

Working with Precision

The default precision settings work well for most projects. If you're working with very large structures like buildings, you might want to be a bit less strict with the precision. For tiny, detailed mechanical parts, you might need more precision. Think of it like adjusting the zoom level on your calculations.

Choosing Which Solutions to Keep

Many constraint operations find multiple valid solutions. You can ask for all of them to see your options, or specify that you only want the first or second solution if you know which arrangement you prefer. This is especially helpful when you're building parametric models where consistency matters.

Understanding Circle Splitting

Some operations can optionally split your input circles at the points where the tangent lines touch them. This creates separate circle segments that you can use for other operations. Most of the time you won't need this feature, but it's there when you do.

Sizing Tangent Circles

When creating tangent circles, start with smaller sizes to understand how the geometry behaves. You can always increase the radius once you see how the circles position themselves. Very large circles might not have valid tangent solutions depending on your input geometry.

Real-World Applications

These constraint operations solve problems that come up frequently in design work. Architects use them for creating smooth transitions in floor plans. Mechanical engineers use them for designing gear systems and smooth mechanical linkages. Even in artistic applications, they help create flowing, mathematically precise curves and connections.

Performance Tips

Constraint calculations can take some time with complex geometry. It's a good idea to test your setup with simple shapes first, then apply the same approach to your full model. This helps you catch any setup issues early and ensures your final results will be what you expect.

Building Complete Workflows

Think of edge constraints as one tool in a larger toolkit. They excel at solving specific geometric relationship problems, and they integrate seamlessly with other modeling operations to help you build exactly what you envision. The mathematical precision they provide becomes the foundation for reliable, parametric design workflows in BitByBit.