Overview
The Arc primitive represents a segment of a circle in 3D space. It is defined by a center point, radius, start angle, end angle, and the number of segments used for tessellation. When the angle range equals 2π, the arc forms a complete circle.
Use Cases:
- Creating circular arcs and curves
- Drawing complete circles
- Rounded corners and fillets
- Circular patterns and designs
Constructor
let arc = OGArc::new(id: String);
const arc = new Arc(options?: IArcOptions);
Rust Constructor Parameters
Unique identifier for the arc instance
TypeScript Constructor Parameters
Configuration options for the arc
Optional unique identifier (auto-generated if not provided)
Starting angle in radians
Number of line segments to approximate the arc (higher = smoother)
Arc color as a hexadecimal number (e.g., 0x00ff00 for green)
Enable thick line rendering using Line2
Line width when fatLines is enabled
Methods
set_config
arc.set_config(
center: Vector3,
radius: f64,
start_angle: f64,
end_angle: f64,
segments: u32
);
Updates the arc’s geometric parameters.arc.setConfig(options: IArcOptions);
Updates the arc configuration and regenerates geometry.
generate_geometry
// Called automatically by setConfig
Generates vertices along the arc using the specified number of segments. For closed arcs (full circles), it automatically creates a face.
get_geometry_serialized
let geometry: String = arc.get_geometry_serialized();
// Used internally for rendering
Returns serialized vertex buffer data as a JSON string.
get_brep_serialized
let brep: String = arc.get_brep_serialized();
const brep = arc.getBrep();
Returns the complete BREP representation including vertices, edges, and faces.
getConfig
const config = arc.getConfig();
Returns the current arc configuration.
discardGeometry
Disposes of the current geometry (called automatically before regeneration).
Properties
Unique identifier for the arc instance
Center point of the arc (default: origin)
Radius of the arc (default: 1.0)
Starting angle in radians (default: 0.0)
Ending angle in radians (default: 2π)
Number of segments for tessellation (default: 32)
Internal BREP representation containing vertices, edges, and optionally a face for closed arcs
Arc color (TypeScript only, settable)
Code Examples
Creating a Semicircle
use opengeometry::primitives::OGArc;
use openmaths::Vector3;
use std::f64::consts::PI;
let mut arc = OGArc::new("arc-1".to_string());
arc.set_config(
Vector3::new(0.0, 0.0, 0.0), // center
5.0, // radius
0.0, // start angle
PI, // end angle (180 degrees)
32 // segments
);
arc.generate_geometry();
import { Arc, Vector3 } from 'opengeometry-three';
const semicircle = new Arc({
center: new Vector3(0, 0, 0),
radius: 5,
startAngle: 0,
endAngle: Math.PI,
segments: 32,
color: 0x00ff00
});
Creating a Full Circle
use std::f64::consts::PI;
let mut circle = OGArc::new("circle-1".to_string());
circle.set_config(
Vector3::new(0.0, 0.0, 0.0),
3.5,
0.0,
2.0 * PI, // Full circle
64 // Higher segments for smoother circle
);
circle.generate_geometry();
const circle = new Arc({
center: new Vector3(0, 0, 0),
radius: 3.5,
startAngle: 0,
endAngle: Math.PI * 2,
segments: 64,
color: 0xff0000
});
Creating a Quarter Arc
const quarterArc = new Arc({
center: new Vector3(5, 0, 5),
radius: 2.0,
startAngle: 0,
endAngle: Math.PI / 2, // 90 degrees
segments: 16,
color: 0x0000ff
});
Using Fat Lines for Arcs
const thickArc = new Arc({
center: new Vector3(0, 0, 0),
radius: 10,
startAngle: 0,
endAngle: Math.PI * 1.5,
segments: 48,
color: 0xff00ff,
fatLines: true,
width: 30
});
Updating Arc Parameters
arc.setConfig({
center: new Vector3(0, 0, 0),
radius: 7.5,
startAngle: Math.PI / 4,
endAngle: Math.PI * 1.75,
segments: 40,
color: 0xffff00
});
// Change color
arc.color = 0x00ffff;