All Projects → rgcv → CGAL.jl

rgcv / CGAL.jl

Licence: MIT license
CGAL meets Julia

Programming Languages

julia
2034 projects

Projects that are alternatives of or similar to CGAL.jl

Cgal
The public CGAL repository, see the README below
Stars: ✭ 2,825 (+13352.38%)
Mutual labels:  geometry, cgal
pyprt
Python bindings for the "Procedural Runtime" (PRT) of CityEngine by Esri.
Stars: ✭ 36 (+71.43%)
Mutual labels:  geometry
alchemy
Generate any a-by-( b + c ) finite rectangle SVG containing potentially Infinitely many a-by-( 2 * b ) finite rectangles animated along a number line of ( ( c - b ) / a )^n scale symmetry.
Stars: ✭ 29 (+38.1%)
Mutual labels:  geometry
BodyParts3D
Clone of the BodyParts3D/Anatomography 3D model files
Stars: ✭ 32 (+52.38%)
Mutual labels:  geometry
pcc geo cnn
Learning Convolutional Transforms for Point Cloud Geometry Compression
Stars: ✭ 44 (+109.52%)
Mutual labels:  geometry
CGoGN 2
n-dimensional Meshes with Combinatorial Maps
Stars: ✭ 19 (-9.52%)
Mutual labels:  geometry
three-strip
Generate strip geometry for three.js. Supports taper, twist, dasharray and uvgen.
Stars: ✭ 15 (-28.57%)
Mutual labels:  geometry
vos whatsapp
vangav open source - whatsapp; generated using vangav backend:
Stars: ✭ 14 (-33.33%)
Mutual labels:  geometry
MidcurveNN
Computation of Midcurve of Thin Polygons using Neural Networks
Stars: ✭ 19 (-9.52%)
Mutual labels:  geometry
featool-multiphysics
FEATool - "Physics Simulation Made Easy" (Fully Integrated FEA, FEniCS, OpenFOAM, SU2 Solver GUI & Multi-Physics Simulation Platform)
Stars: ✭ 190 (+804.76%)
Mutual labels:  geometry
euclid.js
2D Euclidean geometry classes, utilities, and drawing tools
Stars: ✭ 69 (+228.57%)
Mutual labels:  geometry
ludigraphix.github.io
Documentation for Ludigraphix
Stars: ✭ 21 (+0%)
Mutual labels:  geometry
delaunator-rs
Fast 2D Delaunay triangulation in Rust. A port of Delaunator.
Stars: ✭ 115 (+447.62%)
Mutual labels:  geometry
erkir
Երկիր (Erkir) - a C++ library for geodesic and trigonometric calculations
Stars: ✭ 26 (+23.81%)
Mutual labels:  geometry
SeeThere
iOS app for identifying a location through the camera.
Stars: ✭ 18 (-14.29%)
Mutual labels:  geometry
Grass.DirectX
Realistic Grass Rendering using DirectX 11 and a geometry-shader based approach.
Stars: ✭ 56 (+166.67%)
Mutual labels:  geometry
curve-shortening-demo
Visualize curve shortening flow in your browser.
Stars: ✭ 19 (-9.52%)
Mutual labels:  geometry
macuahuitl
The "Macuahuitl" Generative Art Toolbox
Stars: ✭ 68 (+223.81%)
Mutual labels:  geometry
geometry sketcher
Constraint-based geometry sketcher for blender
Stars: ✭ 1,119 (+5228.57%)
Mutual labels:  geometry
geometer
A simple drawing program to replicate construction with a compass and straightedge
Stars: ✭ 19 (-9.52%)
Mutual labels:  geometry

CGAL.jl - CGAL meets Julia

Build Status

DOI This is the Concept DOI. For a specific version, please follow the link.

A package exposing a series of types, constructs, functions, predicates, and algorithms from CGAL (Computational Geometry Algorithms Library), a powerful, reliable, and efficient C++ library

This package is supported by a C++ wrapper around CGAL in the form of libcgal-julia, itself powered by JlCxx.

Usage

Since the kernel is being fixed on the C++ side, the usual typedefs you see in CGAL's examples aren't as common. Here's one of CGAL's examples in a side-by-side comparison with a Julia translation using this package:

C++ Julia
// points_and_segment.cpp
#include <iostream>
#include <CGAL/Simple_cartesian.h>

typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Segment_2 Segment_2;

int main()
{
  Point_2 p(1,1), q(10,10);

  std::cout << "p = " << p << std::endl;
  std::cout << "q = " << q.x() << " " << q.y() << std::endl;

  std::cout << "sqdist(p,q) = "
            << CGAL::squared_distance(p,q) << std::endl;

  Segment_2 s(p,q);
  Point_2 m(5, 9);

  std::cout << "m = " << m << std::endl;
  std::cout << "sqdist(Segment_2(p,q), m) = "
            << CGAL::squared_distance(s,m) << std::endl;

  std::cout << "p, q, and m ";
  switch (CGAL::orientation(p,q,m)){
  case CGAL::COLLINEAR:
    std::cout << "are collinear\n";
    break;
  case CGAL::LEFT_TURN:
    std::cout << "make a left turn\n";
    break;
  case CGAL::RIGHT_TURN:
    std::cout << "make a right turn\n";
    break;
  }

  std::cout << " midpoint(p,q) = " << CGAL::midpoint(p,q) << std::endl;
  return 0;
}
# points_and_segment.jl
using CGAL

p, q = Point2(1, 1), Point2(10, 10)

println("p = $p")
println("q = $(x(q)) $(y(q))")

println("sqdist(p,q) = $(squared_distance(p, q))")

s = Segment2(p, q)
m = Point2(5, 9)

println("m = $m")
println("sqdist(Segment2(p,q), m) = $(squared_distance(s, m))")

print("p, q, and m ")
let o = orientation(p, q, m)
    if     o == COLLINEAR  println("are collinear")
    elseif o == LEFT_TURN  println("make a left turn")
    elseif o == RIGHT_TURN println("make a right turn")
    end
end

println(" midpoint(p,q) = $(midpoint(p, q))")

Installation

Drop into a REPL and type the following:

julia> import Pkg; Pkg.add("CGAL")

Alternatively, in a blank REPL, after hitting ],

pkg> add CGAL

Using a different kernel

Currently, two different binary libraries are made available in libcgal-julia: one compiled with the Exact_predicates_inexact_constructions_kernel, and another one with Exact_predicates_exact_constructions_kernel_with_sqrt (i.e. using doubles => Float64, and CORE::Expr => FieldType). By default, this package uses the inexact variant, trading better performance for minor, even sometimes negligible, dare I say, inexact results.

There are two different ways of loading a custom library, both of which come in the form of defining environment variables. One of the glaring downsides of this approach is the package must be rebuilt in order to pick up the change before loading the module due to precompilation.

On the julia side of things, this distinction is made based on the existence of a FieldType type mapped from the C++ side. Take a look inside kernel.jl to see how this is handled.

Switching between inexact/exact kernels

In order to use a kernel with exact constructions, one must define the JLCGAL_EXACT_CONSTRUCTIONS environment variable. The variable's value is ignored. It only needs to exist. For example,

$ export JLCGAL_EXACT_CONSTRUCTIONS="I'm willing to pay for some performance penalties"
$ julia
julia> build CGAL
...
julia> using CGAL
...
julia> FT
FieldType # numeric type from CGAL. when using inexact constructions => Float64

Loading a custom wrapper library

The full path to an alternative version of the wrapper library can be specified by defining the JLCGAL_LIBPATH environment variable. This will override the JLCGAL_EXACT_CONSTRUCTIONS definition since the former is more specific than the latter.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].