Skip to main content

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);

Rust Constructor Parameters

id
String
required
Unique identifier for the arc instance

TypeScript Constructor Parameters

options
IArcOptions
Configuration options for the arc
options.ogid
string
Optional unique identifier (auto-generated if not provided)
options.center
Vector3
required
Center point of the arc
options.radius
number
required
Radius of the arc
options.startAngle
number
required
Starting angle in radians
options.endAngle
number
required
Ending angle in radians
options.segments
number
required
Number of line segments to approximate the arc (higher = smoother)
options.color
number
required
Arc color as a hexadecimal number (e.g., 0x00ff00 for green)
options.fatLines
boolean
default:"false"
Enable thick line rendering using Line2
options.width
number
default:"20"
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.

generate_geometry

arc.generate_geometry();
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();
Returns serialized vertex buffer data as a JSON string.

get_brep_serialized

let brep: String = arc.get_brep_serialized();
Returns the complete BREP representation including vertices, edges, and faces.

getConfig

const config = arc.getConfig();
Returns the current arc configuration.

discardGeometry

arc.discardGeometry();
Disposes of the current geometry (called automatically before regeneration).

Properties

id
String
Unique identifier for the arc instance
center
Vector3
Center point of the arc (default: origin)
radius
f64
Radius of the arc (default: 1.0)
start_angle
f64
Starting angle in radians (default: 0.0)
end_angle
f64
Ending angle in radians (default: 2π)
segments
u32
Number of segments for tessellation (default: 32)
brep
Brep
Internal BREP representation containing vertices, edges, and optionally a face for closed arcs
color
number
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();

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();

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;
Last modified on March 7, 2026