#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 620
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass scrreprt
\begin_preamble
\PassOptionsToPackage{usenames,dvipsnames}{xcolor}
\usepackage[dvipsnames]{xcolor}

\usepackage[T1]{fontenc}

%\usepackage{hyperref}
%\usepackage{lstlinebgrd}

\definecolor{bl}{rgb}{0.0,0.2,0.6} 

\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{lightgray}{rgb}{0.95,0.95,0.95}
\definecolor{mymauve}{rgb}{0.58,0,0.82}

\hypersetup{colorlinks=true, citecolor=blue, linkcolor=blue}

% package that modifies style of section headers
\addtokomafont{chapter}{\color{bl}\scshape \selectfont}
\addtokomafont{section}{\color{bl}\scshape \selectfont}
\addtokomafont{subsection}{\color{bl}\scshape \selectfont}
\addtokomafont{subsubsection}{\color{bl}\scshape \selectfont}

% setup font style for different title elements
\setkomafont{title}{\color{bl} \bfseries \scshape}
\setkomafont{author}{\centering \small}
\setkomafont{date}{\centering \small}


% Change the abstract environment
\usepackage[runin]{abstract}		% runin option for a run-in title
\setlength\absleftindent{30pt}		% left margin
\setlength\absrightindent{30pt}		% right margin
\abslabeldelim{\quad }			
\setlength{\abstitleskip}{-10pt}
\renewcommand{\abstractname}{}
\renewcommand{\abstracttextfont}{\color{bl} \small \slshape }	% slanted text


% Custom headers and footers using KOMA-Script
\usepackage{scrlayer-scrpage}
\usepackage{lastpage}	% for page numbering	

% Left header: chapter title on even pages
\lehead{\slshape\leftmark}
\lohead{}
% Center header: empty
\chead{}
% Right header: section title on odd pages
\rehead{}
\rohead{\slshape\rightmark}

% Outer footer (left of even pages, right of odd pages)
\KOMAoptions{footsepline=on}
\ofoot[\footnotesize page \thepage\ / \pageref{LastPage}]{\footnotesize page \thepage\ / \pageref{LastPage}}
% Center footer: empty
\cfoot{}
% Inner footer (right of even pages, left of odd pages)
\ifoot[\footnotesize \jobname]{\footnotesize \jobname}

% left chapter no number, nothing on the right
\renewcommand{\chaptermark}[1]{\markboth{\thechapter\ #1}{}}
% right section with number
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}

% Added by lyx2lyx
\usepackage[charter]{mathdesign}

% setup of figure captions 
\usepackage[format=plain,font=it,labelfont=bf]{caption}


% To add mini-TOC in the beginning of each chapter
% The 'nohints' option is to prevent a conflict with the lastpage package, 
% resulting in an extra empty page at the end of the document.
\usepackage[nohints]{minitoc}


% "Prettification" of Matlab listings
\usepackage{matlab-prettifier}

\usepackage{hyperref}

% some info for populating document title page
\author{D. Legland}
\date{\today}
\end_preamble
\options idxtotoc
\use_default_options true
\maintain_unincluded_children no
\language english
\language_package default
\inputencoding auto-legacy
\fontencoding auto
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_roman_osf false
\font_sans_osf false
\font_typewriter_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\use_microtype false
\use_dash_ligatures true
\graphics default
\default_output_format pdf2
\output_sync 1
\bibtex_command default
\index_command default
\float_placement h
\float_alignment class
\paperfontsize default
\spacing single
\use_hyperref true
\pdf_bookmarks true
\pdf_bookmarksnumbered false
\pdf_bookmarksopen false
\pdf_bookmarksopenlevel 1
\pdf_breaklinks false
\pdf_pdfborder false
\pdf_colorlinks false
\pdf_backref false
\pdf_pdfusetitle true
\papersize a4
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine natbib
\cite_engine_type authoryear
\biblio_style plainnat
\use_bibtopic false
\use_indices true
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 0
\use_formatted_ref 0
\use_minted 0
\use_lineno 0
\index Index of functions
\shortcut idx
\color #008000
\end_index
\index General index
\shortcut gen
\color #008000
\end_index
\secnumdepth 3
\tocdepth 1
\paragraph_separation indent
\paragraph_indentation default
\is_math_indent 0
\math_numbering_side default
\quotes_style english
\dynamic_quotes 0
\papercolumns 1
\papersides 2
\paperpagestyle default
\tablestyle default
\listings_params "language=Matlab,style={Matlab-editor},tabsize=2,frame=single,breaklines=true,basicstyle={\scriptsize\mlttfamily},aboveskip=5pt,showspaces=false"
\tracking_changes false
\output_changes false
\change_bars false
\postpone_fragile_content false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\docbook_table_output 0
\docbook_mathml_prefix 1
\end_header

\begin_body

\begin_layout Title
MatGeom library user manual
\end_layout

\begin_layout Abstract
The MatGeom (for 
\begin_inset Quotes eld
\end_inset

Matlab Geometry
\begin_inset Quotes erd
\end_inset

) library provides a collection of functions for geometric computing within the Matab environment.
 It is organised in several modules,
 devoted to generic computations in 2D or 3D,
 polylines and polygons operators,
 3D meshes operators,
 or geometric graphs operators.
 Many plotting functions are provided to facilitate the graphical representation of computation results.
 The library is provided with a large amount of user help:
 code comments,
 function headers,
 demonstration scripts...
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
dominitoc
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset CommandInset toc
LatexCommand tableofcontents

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Standard
\begin_inset Note Note
status open

\begin_layout Plain Layout
TODO:
\end_layout

\begin_layout Itemize
Quick tours
\end_layout

\begin_deeper
\begin_layout Itemize
one for 3D?
 
\end_layout

\end_deeper
\begin_layout Itemize
add bibliography
\end_layout

\begin_deeper
\begin_layout Itemize
Ilya Belevich
\end_layout

\end_deeper
\begin_layout Itemize
add sample shapes (sedgewick,
 meshes...)
\end_layout

\end_inset


\end_layout

\begin_layout Chapter
Overview
\end_layout

\begin_layout Standard
MatGeom is a library for geometric computing with Matlab in 2D and 3D.
 The official homepage for the project is hosted on GitHub
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
\begin_inset Flex URL
status open

\begin_layout Plain Layout

http://github.com/mattools/matGeom
\end_layout

\end_inset


\end_layout

\end_inset

.
\end_layout

\begin_layout Standard
MatGeom is a 
\begin_inset Quotes eld
\end_inset

function-based
\begin_inset Quotes erd
\end_inset

 library:
 it contains several hundreds of functions for the creation,
 the manipulation and the display of 2D and 3D shapes such as point sets,
 lines,
 polygons,
 3D meshes,
 ellipses...
 The following sections provide a quick overview of the features in the library.
\end_layout

\begin_layout Section
Simple geometries
\end_layout

\begin_layout Standard
Basic functionalities comprise creation of simple geometries such as points,
 lines,
 ellipses...
 An example is provided in figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:geom2d-Demo"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

,
 based on the following script.
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

% load data
\end_layout

\begin_layout Plain Layout

data = load('fisheriris');
\end_layout

\begin_layout Plain Layout

pts = data.meas(:,
 [3 1]);
\end_layout

\begin_layout Plain Layout

% display
\end_layout

\begin_layout Plain Layout

figure;
 axis equal;
 hold on;
 axis([0 8 3 9]);
\end_layout

\begin_layout Plain Layout

drawPoint(pts,
 'bx');
\end_layout

\begin_layout Plain Layout

% Fit line
\end_layout

\begin_layout Plain Layout

line = fitLine(pts);
\end_layout

\begin_layout Plain Layout

drawLine(line,
 'color',
 'k',
 'linewidth',
 2);
\end_layout

\begin_layout Plain Layout

% Draw oriented box
\end_layout

\begin_layout Plain Layout

obox = orientedBox(pts);
\end_layout

\begin_layout Plain Layout

drawOrientedBox(obox,
 'color',
 'k',
 'linewidth',
 1);
\end_layout

\begin_layout Plain Layout

% identifiy species index
\end_layout

\begin_layout Plain Layout

[labels,
 ~,
 inds]= unique(str.species);
\end_layout

\begin_layout Plain Layout

% for ech species,
 compute equivalent ellipse and display with axes
\end_layout

\begin_layout Plain Layout

colors = [1 0 0;
 0 0.8 0;
 0 0 1];
\end_layout

\begin_layout Plain Layout

for i = 1:3
\end_layout

\begin_layout Plain Layout

    pts_i = pts(inds == i,
 :);
\end_layout

\begin_layout Plain Layout

    drawPoint(pts_i,
 'marker',
 'x',
 'color',
 colors(i,:),
 'linewidth',
 2);
\end_layout

\begin_layout Plain Layout

    elli = equivalentEllipse(pts_i);
\end_layout

\begin_layout Plain Layout

    drawEllipse(elli,
 'color',
 colors(i,:),
 'linewidth',
 2)
\end_layout

\begin_layout Plain Layout

    drawEllipseAxes(elli,
 'color',
 colors(i,:),
 'linewidth',
 2)
\end_layout

\begin_layout Plain Layout

end
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/geom2d/demo_geom2d_iris.png
	width 48text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Equivalent ellipse and line fitting.
\end_layout

\end_inset


\end_layout

\end_inset


\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/polygons2d/leafPoly_variousOps.png
	width 48text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Polygon geometry pocessing
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:geom2d-Demo"

\end_inset

Illustration of geometry processing in 2D.
 (a) Computation of equivalent ellipses,
 of enclosing oriented box,
 and line fitting.
 (b) Summary of polygon processing operations:
 smoothing,
 simplification,
 convex hull,
 intersection with lines.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Section
Polygon processing
\end_layout

\begin_layout Standard
The polygons modules provides a variety of functions for manipulation and processing of polygons.
 Common operations comprise smoothing,
 simplification (retaining only a selection of vertices),
 computation of convex hull or of intersections with other geometric primitives.
 A summary of typical operations in presented in figure 
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:geom2d-Demo"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-b.
\end_layout

\begin_layout Standard
The listing of the script used for generating the figure is given below.
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

% read polygon data as a numeric N-by-2 array
\end_layout

\begin_layout Plain Layout

poly = load('leaf_poly.txt');
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

% dislay the polygon using basic color option
\end_layout

\begin_layout Plain Layout

figure;
 axis equal;
 hold on;
 axis([0 600 0 400]);
\end_layout

\begin_layout Plain Layout

drawPolygon(poly,
 'k');
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

% Bounding box of the polygon
\end_layout

\begin_layout Plain Layout

poly_bnd = boundingBox(poly);
\end_layout

\begin_layout Plain Layout

drawBox(poly_bnd,
 'k');
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

% computes convex hull of polygon vertices
\end_layout

\begin_layout Plain Layout

poly_hull = convexHull(poly);
\end_layout

\begin_layout Plain Layout

drawPolygon(poly_hull,
 'LineWidth',
 2,
 'Color',
 'k');
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

% applies smoothing to the original polygon.
\end_layout

\begin_layout Plain Layout

poly_smooth = smoothPolygon(poly,
 51);
\end_layout

\begin_layout Plain Layout

drawPolygon(poly_smooth,
 'color',
 'b',
 'linewidth',
 2);
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

% Computes a simplified version of the polygon
\end_layout

\begin_layout Plain Layout

poly_simpl = simplifyPolygon(poly,
 20);
\end_layout

\begin_layout Plain Layout

drawPolygon(poly_simpl,
 'color',
 'r',
 'linewidth',
 2);
\end_layout

\begin_layout Plain Layout

drawVertices(poly_simpl,
 'Color',
 'k',
 'Marker',
 's',
 'MarkerFaceColor',
 'w');
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

% compute intersections with an arbitrary line
\end_layout

\begin_layout Plain Layout

line = createLine([0 250],
 [600 350]);
\end_layout

\begin_layout Plain Layout

drawLine(line,
 'k');
\end_layout

\begin_layout Plain Layout

inters = intersectLinePolygon(line,
 poly_simpl);
\end_layout

\begin_layout Plain Layout

drawPoint(inters,
 'Color',
 'r',
 'Marker',
 'o',
 'MarkerFaceColor',
 'w',
 'linewidth',
 2);
\end_layout

\end_inset


\end_layout

\begin_layout Chapter
Installation and principles
\end_layout

\begin_layout Section
Installation
\end_layout

\begin_layout Standard
There are several possibilities for installing the MatGeom library.
\end_layout

\begin_layout Subsection
Install as Add-On
\end_layout

\begin_layout Standard
This is the simplest method.
 Simply open the 
\begin_inset Quotes eld
\end_inset

Add-Ons
\begin_inset Quotes erd
\end_inset

 button from the toolbar of the main Matlab frame,
 and look for 
\begin_inset Quotes eld
\end_inset

MatGeom
\begin_inset Quotes erd
\end_inset

.
 Select the library,
 and click on 
\begin_inset Quotes eld
\end_inset

Install
\begin_inset Quotes erd
\end_inset

.
 That's it!
\end_layout

\begin_layout Subsection
Install as Toolbox manually 
\end_layout

\begin_layout Standard
The latest version of the toolbox can also be downloaded manually as a 
\begin_inset Quotes eld
\end_inset

.mltx
\begin_inset Quotes erd
\end_inset

 file.
 When executing the file from Matlab,
 the toolbox is automatically installed.
\end_layout

\begin_layout Subsection
Download zip archive
\end_layout

\begin_layout Standard
Most versions provide an archive of the whole library in a zip file.
 The library an be installed by decompressing the archive,
 and running the 
\begin_inset Quotes eld
\end_inset

setupMatGeom.m
\begin_inset Quotes erd
\end_inset

 script.
 You also have access to unit tests and demonstration scripts.
\end_layout

\begin_layout Subsection
Latest development version (for developers)
\end_layout

\begin_layout Standard
If you prefere to get the latest version,
 you can clone the project from the project homepage
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
\begin_inset Flex URL
status open

\begin_layout Plain Layout

http://github.com/mattools/matGeom
\end_layout

\end_inset


\end_layout

\end_inset

.
 A basic knowledge of the Git system is required.
 An advantage of this method is that it is possible to synchronize with latest development,
 while keeping local modifications.
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Library organisation
\end_layout

\begin_layout Standard
The library is organised into several modules:
\end_layout

\begin_layout Description
geom2d General functions in euclidean plane (described in chapter 
\begin_inset CommandInset ref
LatexCommand ref
reference "chap:geom2d"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

)
\end_layout

\begin_layout Description
polygons2d Functions operating on point lists (described in chapter 
\begin_inset CommandInset ref
LatexCommand ref
reference "chap:polygons2d"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

)
\end_layout

\begin_layout Description
graphs Manipulation of geometric graphs (described in chapter 
\begin_inset CommandInset ref
LatexCommand ref
reference "chap:Graphs"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

)
\end_layout

\begin_layout Description
geom3d General functions in 3D euclidean space (described in chapter 
\begin_inset CommandInset ref
LatexCommand ref
reference "chap:geom3d"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

)
\end_layout

\begin_layout Description
meshes3d Manipulation of 3D polygonal meshes (described in chapter 
\begin_inset CommandInset ref
LatexCommand ref
reference "chap:meshes3d"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

)
\end_layout

\begin_layout Standard
There are dependencies between modules.
 For examples,
 the 
\series bold
polygons2d
\series default
 and the 
\series bold
geom3d
\series default
 modules both depend on the 
\series bold
geom2d
\series default
 module.
 Several fucntions of the 
\series bold
graphs 
\series default
module depend on the geom2d module.
 The 
\series bold
meshes 
\series default
module depends on both the geom3d and the graphs module.
\end_layout

\begin_layout Standard
The 
\series bold
obsolete
\series default
 directory contains functions that were developped in previous versions of the library,
 and that are kept to facilitate the transition from older versions.
\end_layout

\begin_layout Standard
See also the organization of the project in the developer section (chapter 
\begin_inset CommandInset ref
LatexCommand ref
reference "chap:Developer-Side"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Usage principles
\end_layout

\begin_layout Standard
The general idea is to represent each geometry with numeric arrays.
 
\begin_inset Quotes eld
\end_inset

Simple
\begin_inset Quotes erd
\end_inset

 geometries such as points,
 lines,
 circles...
 are represented by concatenating parameters within a single row vector.
 
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

PNT = [20 30 40];
                        % create a 3D point 
\end_layout

\begin_layout Plain Layout

EDGE = [0 0  50 30];
                     % create a line segment between (0,0) and (50,30)
\end_layout

\begin_layout Plain Layout

CIRCLE = [50 50 10];
                     % create a circle,
 center (50,50) and radius 10
\end_layout

\begin_layout Plain Layout

ELLI = [50 50  40 20  30];
               % ellipse with center (50,50),
 radius lengths 40 and 20,
 
\end_layout

\begin_layout Plain Layout

                                         % and an orientation 30 degreees.
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Simple geometry data may be concatenated to represent an array of geometries:
 each row of the array represents one geometry.
\end_layout

\begin_layout Standard
Geometries involving a variable number of vertices such as polygons and polylines are represented with the array of vertex coordinates:
 
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

POLY = [0 0;10 0;10 10;0 10];
            % create a polygon or polyline with four vertices
\end_layout

\end_inset


\end_layout

\begin_layout Standard
More complex geometries such as graphs or meshes are represented by a list of variables.
 
\end_layout

\begin_layout Standard
Functions operate on inputs usually describes within the name:
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

D = distancePointLine(P1,
 L2);
           % compute distance between a point a line
\end_layout

\begin_layout Plain Layout

POLY2 = simplifyPolygon(POLY,
 5);
        % compute a simplified version of a polygon
\end_layout

\begin_layout Plain Layout

RINGS = intersectPlaneMesh(PLN,
 MESH);
   % compute intersection between a plane and a mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
A number of drawing functions is provided to display the geometric data.
 The name pattern is 
\begin_inset Quotes eld
\end_inset

drawXXX
\begin_inset Quotes erd
\end_inset

 or 
\begin_inset Quotes eld
\end_inset

fillXXX
\begin_inset Quotes erd
\end_inset

,
 where XXX is the geometry to display:
 drawEllipse,
 fillPolygon,
 drawMesh...
 They usually accept the geometry representation as first input argument,
 and optional arguments for specifying the drawing style.
 The axis object containing the display may also be specified as optional first argument,
 in a similar way to Matlab's drawing functions.
 A handle to the resulting graphical object may be returned as output argument.
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

drawLine(L1,
 'LineWidth',
 2);
            % draw a line,
 specifying drawing options
\end_layout

\begin_layout Plain Layout

HC = drawCircle(AX,
 C1,
 'Color',
 'b');
   % draw a circle on specific axis and return handle
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Getting help
\end_layout

\begin_layout Standard
The user manuel (this document) provides an overview of the library,
 and a short description of most functions.
 
\end_layout

\begin_layout Standard
Each function contains a header with additional information.
 Most of the time,
 the syntax,
 and example and related functions are provided.
 Example for the polygonCentroid function:
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

>> help polygonCentroid
\end_layout

\begin_layout Plain Layout

 Computes the centroid (center of mass) of a polygon.
\end_layout

\begin_layout Plain Layout

 
\end_layout

\begin_layout Plain Layout

    CENTROID = polygonCentroid(POLY)
\end_layout

\begin_layout Plain Layout

    CENTROID = polygonCentroid(PTX,
 PTY)
\end_layout

\begin_layout Plain Layout

    Computes center of mass of a polygon defined by POLY.
 POLY is a N-by-2
\end_layout

\begin_layout Plain Layout

    array of double containing coordinates of vertices.
\end_layout

\begin_layout Plain Layout

 
\end_layout

\begin_layout Plain Layout

    [CENTROID,
 AREA] = polygonCentroid(POLY)
\end_layout

\begin_layout Plain Layout

    Also returns the (signed) area of the polygon.
 
\end_layout

\begin_layout Plain Layout

 
\end_layout

\begin_layout Plain Layout

    Example
\end_layout

\begin_layout Plain Layout

      % Draws the centroid of a paper hen
\end_layout

\begin_layout Plain Layout

      x = [0 10 20  0 -10 -20 -10 -10  0];
\end_layout

\begin_layout Plain Layout

      y = [0  0 10 10  20  10  10  0 -10];
\end_layout

\begin_layout Plain Layout

      poly = [x' y'];
\end_layout

\begin_layout Plain Layout

      centro = polygonCentroid(poly);
\end_layout

\begin_layout Plain Layout

      drawPolygon(poly);
\end_layout

\begin_layout Plain Layout

      hold on;
 axis equal;
\end_layout

\begin_layout Plain Layout

      drawPoint(centro,
 'bo');
\end_layout

\begin_layout Plain Layout

  
\end_layout

\begin_layout Plain Layout

    References
\end_layout

\begin_layout Plain Layout

      algo adapted from P.
 Bourke web page.
\end_layout

\begin_layout Plain Layout

 
\end_layout

\begin_layout Plain Layout

    See also:
\end_layout

\begin_layout Plain Layout

      polygons2d,
 polygonArea,
 polygonSecondAreaMoments,
 drawPolygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Typing 
\begin_inset Quotes eld
\end_inset

help geom2d
\begin_inset Quotes erd
\end_inset

 (or another module name) displays a list of the functions within the module.
\end_layout

\begin_layout Section
General conventions
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "sec:General-conventions"

\end_inset


\end_layout

\begin_layout Standard
The MatGeom library tries to follow standard conventions and practices both from mathematical and Matlab-programming point of view.
 Conventions are recalled within the manual or in function headers when appropriate.
\end_layout

\begin_layout Standard
Function names follow the (lower) 
\begin_inset Quotes eld
\end_inset

came case
\begin_inset Quotes erd
\end_inset

 convention.
 Example:
 
\family typewriter
drawLine
\family default
.
 Functions start either by a verb at the infinitive,
 or by a noun (when working on a specific data structure).
 Examples:
 
\family typewriter
clipPolygon
\family default
,
 
\family typewriter
polygonCentroid
\family default
.
\end_layout

\begin_layout Standard
Angles are in radians,
 except when they are used to define the orientation of geometries.
 In that case,
 they are given as degrees (usually more intuitive).
\end_layout

\begin_layout Chapter
Module geom2d
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "chap:geom2d"

\end_inset


\end_layout

\begin_layout Standard
The geom2d module of the MatGeom library allows to process geometric planar shapes such as point sets,
 edges,
 straight lines,
 bounding boxes,
 conics (circles and ellipses)...
 Most functions works for planar shapes,
 but some ones have been extended to 3D or to any dimension.
 Other modules provide additional functions for specific shapes:
 polygons2d,
 graphs,
 polynomialCurves2d.
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
minitoc
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Introduction
\end_layout

\begin_layout Standard
The geom2d module provides functions for processing points,
 vectors,
 linear shapes (including straight lines,
 line segments,
 or rays),
 as well as smooth curves such as circles or ellipses.
 
\end_layout

\begin_layout Standard
\begin_inset Float table
placement h
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="8" columns="4">
<features tabularvalignment="middle">
<column alignment="left" valignment="top">
<column alignment="center" valignment="top">
<column alignment="left" valignment="top">
<column alignment="left" valignment="top">
<row>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Geometry
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Size
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Params.
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Comments
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" topline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
point,
 vector
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $1\times2$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $[x,y]$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Coordinates
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
line
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $1\times4$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $[x_{0},y_{0},d_{x},d_{y}]$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Origin and direction
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
segment
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $1\times4$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $[x_{1},y_{1},x_{2},y_{2}]$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Extremity points
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
circle
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $1\times3$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $[x_{c},y_{c},r]$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Center and radius
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
ellipse
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $1\times5$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $[x_{c},y_{c},r_{a},r_{b},\theta]$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Center,
 sizes,
 orientation
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
box
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $1\times4$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $[x_{min},x_{max},y_{min},y_{max}]$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="1">
<features tabularvalignment="middle">
<column alignment="none" valignment="top" special="@{}c@{}">
<row>
<cell alignment="none" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Used for bounding boxes
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="none" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
and clipping
\end_layout

\end_inset
</cell>
</row>
</lyxtabular>

\end_inset


\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
oriented box
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $1\times5$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $[x_{c},y_{c},l,w,\theta]$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Center,
 sizes,
 orientation
\end_layout

\end_inset
</cell>
</row>
</lyxtabular>

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "tab:Geometries2D"

\end_inset

Summary of 2D geometry representations.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Standard
Geometries are represented using row vectors (see table 
\begin_inset CommandInset ref
LatexCommand ref
reference "tab:Geometries2D"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
 The simplest geometric primitives are points and vectors.
 They are represented by 
\begin_inset Formula $1\times2$
\end_inset

 row vectors containing the coordinates.
 Straight lines are represented by 
\begin_inset Formula $1\times4$
\end_inset

 row vectors concatenating origin point and direction vector.
 Circles,
 ellipses and ellipsoids concatenate the center of the geometry,
 the list of radius determining its size,
 and an optional orientation.
 For 2D geometries,
 the orientation is given as a single angle in degrees.
\end_layout

\begin_layout Section
Points and vectors
\end_layout

\begin_layout Standard
Points and vectors are the most elementary geometric entities.
 Both points and vectors are defined by their two cartesian coordinates,
 stored into a row vector of 2 elements:
 
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

pt = [x y];
\end_layout

\begin_layout Plain Layout

vect = [vx vy];
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Point sets and vector sets are stored in a matrix with two columns,
 one for the x-coordinate,
 one for the y-coordinate:
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

pts = [x1 y1 ;
 x2 y2 ;
 x3 y3];
\end_layout

\begin_layout Plain Layout

vectList = [vx1 vy1 ;
 vx2 vy2 ;
 vx3 vy3];
\end_layout

\end_inset


\end_layout

\begin_layout Subsection
Points
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "subsec:Point"

\end_inset


\end_layout

\begin_layout Standard
General functions operating on points.
\end_layout

\begin_layout Minisec
points2d 
\end_layout

\begin_layout Standard
Description of functions operating on points.
\end_layout

\begin_layout Minisec
midPoint
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
midPoint
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Middle point of two points or of an edge.
\end_layout

\begin_layout Minisec
circumCenter
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
circumCenter
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Circumcenter of three points.
\end_layout

\begin_layout Minisec
isCounterClockwise
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isCounterClockwise
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes relative orientation of 3 points.
\end_layout

\begin_layout Minisec
polarPoint
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polarPoint
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a point from polar coordinates (rho + theta).
\end_layout

\begin_layout Minisec
angle2Points
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angle2Points
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes horizontal angle between 2 points.
 See also section 
\begin_inset CommandInset ref
LatexCommand ref
reference "subsec:Angles"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Minisec
angle3Points
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angle3Points
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes oriented angle made by 3 points.
\end_layout

\begin_layout Minisec
distancePoints
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distancePoints
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distance!points
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes distance between two points.
\end_layout

\begin_layout Minisec
transformPoint
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
transformPoint
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Applies an affine transform to a point or a point array.
 See also section 
\begin_inset CommandInset ref
LatexCommand ref
reference "sec:Transforms"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Minisec
drawPoint
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawPoint
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws the point(s) on the axis.
\end_layout

\begin_layout Subsection
Point Sets
\end_layout

\begin_layout Standard
The following listings provides an overview of some functions operating on point sets.
 The result is shown on Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Point-Set"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

% generate random data
\end_layout

\begin_layout Plain Layout

rng(42);
 pts = randn([100 2]) * 15 + 50;
\end_layout

\begin_layout Plain Layout

% compute derived shapes
\end_layout

\begin_layout Plain Layout

centro = centroid(pts);
 bbox = boundingBox(pts);
\end_layout

\begin_layout Plain Layout

elli = equivalentEllipse(pts);
 hull = convexHull(pts);
\end_layout

\begin_layout Plain Layout

% display shapes
\end_layout

\begin_layout Plain Layout

figure;
 hold on;
 axis([0 100 0 100]);
\end_layout

\begin_layout Plain Layout

drawPoint(pts,
 'color',
 'k',
 'marker',
 'o',
 'linewidth',
 2);
\end_layout

\begin_layout Plain Layout

drawPoint(centPts,
 'color',
 'b',
 'marker',
 '*',
 'linewidth',
 2,
 'MarkerSize',
 10);
\end_layout

\begin_layout Plain Layout

drawBox(bbox,
 'color',
 [0 0 .7],
 'linewidth',
 2);
\end_layout

\begin_layout Plain Layout

drawEllipse(elli,
 'color',
 [.7 0 0],
 'linewidth',
 2);
\end_layout

\begin_layout Plain Layout

drawPolygon(hull,
 'color',
 [0 .7 0],
 'linewidth',
 2);
\end_layout

\begin_layout Plain Layout

legend({'Points',
 'Centroid',
 'BoundingBox',
 'Equiv.
 Ellipse',
 'Conv.
 Hull'},
 'Location',
 'NorthEast');
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/geom2d/points2d_demo.png
	lyxscale 50
	width 75text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Point-Set"

\end_inset

Generation of a random point set and computation of geometric derived shapes.
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\end_layout

\begin_layout Minisec
clipPoints
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipPoints
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipping!points
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Clips a set of points by a box.
\end_layout

\begin_layout Minisec
centroid
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
centroid
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
centroid!points
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "fun:centroid"

\end_inset

Computes the centroid (center of mass) of a set of points.
\end_layout

\begin_layout Minisec
boundingBox
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
boundingBox
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Bounding box of a set of points.
\end_layout

\begin_layout Minisec
principalAxes
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
principalAxes
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Principal axes of a set of ND points,
 returned as a centroid,
 a rotation matrix,
 and optionally a scaling factor.
 See also EquivalentEllipse and EquivalentEllipsoid.
\end_layout

\begin_layout Minisec
angleSort
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angleSort
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Sorts points in the plane according to their angle to origin.
\end_layout

\begin_layout Minisec
findClosestPoint
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
findClosestPoint
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Finds index of closest point in an array.
\end_layout

\begin_layout Minisec
minDistancePoints
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
minDistancePoints
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distance!points
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Minimal distance between several points.
\end_layout

\begin_layout Minisec
mergeClosePoints
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
mergeClosePoints
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Merges points that are closer than a given distance.
\end_layout

\begin_layout Minisec
hausdorffDistance
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
hausdorffDistance
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Hausdorff distance between two point sets.
\end_layout

\begin_layout Minisec
nndist
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
nndist
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
nearest neighbor
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Nearest-neighbor distances of each point in a set.
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Subsection
Vectors
\end_layout

\begin_layout Standard
General functions operating on vectors.
\end_layout

\begin_layout Minisec
vectors2d 
\end_layout

\begin_layout Standard
Description of functions operating on plane vectors.
\end_layout

\begin_layout Minisec
createVector
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createVector
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a vector from two points.
\end_layout

\begin_layout Minisec
vectorNorm
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
vectorNorm
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes norm of a vector,
 or of a set of vectors.
\end_layout

\begin_layout Minisec
vectorAngle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
vectorAngle
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angle!vector
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Angle of a vector,
 or between 2 vectors.
\end_layout

\begin_layout Minisec
normalizeVector
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
normalizeVector
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Normalizes a vector to have norm equal to 1.
\end_layout

\begin_layout Minisec
isPerpendicular
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isPerpendicular
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Checks orthogonality of two vectors.
\end_layout

\begin_layout Minisec
isParallel
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isParallel
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Checks parallelism of two vectors.
\end_layout

\begin_layout Minisec
transformVector
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
transformVector
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Transforms a vector with an affine transform.
\end_layout

\begin_layout Minisec
rotateVector
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
rotateVector
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Rotates a vector by a given angle.
\end_layout

\begin_layout Subsection
Various drawing functions
\end_layout

\begin_layout Standard
Some functions allow to draw less standard objects.
\end_layout

\begin_layout Minisec
drawVector
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawVector
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws vector at a given position.
\end_layout

\begin_layout Minisec
drawArrow
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawArrow
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draws an arrow on the current axis.
\end_layout

\begin_layout Minisec
drawLabels
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawLabels
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws labels at specified positions.
\end_layout

\begin_layout Minisec
drawShape
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawShape
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws various types of shapes (circles,
 polygons...).
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Linear shapes
\end_layout

\begin_layout Standard
Linear shapes encompass three kinds of shapes:
\end_layout

\begin_layout Description
straight
\begin_inset space ~
\end_inset

lines are infinite in ech direction
\end_layout

\begin_layout Description
line
\begin_inset space ~
\end_inset

segments,
\begin_inset space ~
\end_inset

or
\begin_inset space ~
\end_inset

edges correspond to the set of points between two extremity points
\end_layout

\begin_layout Description
rays emanate from a point,
 and are unbounded in one direction
\end_layout

\begin_layout Standard
They all can be represented by a parametric equation of the form:
\begin_inset Formula 
\[
\mathbf{x}=\mathbf{x}_{0}+t\mathbf{v}
\]

\end_inset

where 
\begin_inset Formula $\mathbf{x}_{0}=(x_{0,x},x_{0,y})$
\end_inset

 is the origin of the linear geometry,
 
\begin_inset Formula $\mathbf{v}=(v_{x},v_{y})$
\end_inset

 is its direction vector,
 and 
\begin_inset Formula $t$
\end_inset

 is the parameter,
 with 
\begin_inset Formula $t\in[0,1]$
\end_inset

 for line segments,
 
\begin_inset Formula $t\in\mathbb{R}^{+}$
\end_inset

 for ray,
 and 
\begin_inset Formula $t\in\mathbb{R}$
\end_inset

 for straight lines.
 An example of each of these three shapes is represented on Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Line-Shape-Examples"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
 
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/geom2d/lines2d_data.png
	lyxscale 50
	width 50text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Line-Shape-Examples"

\end_inset

Three examples of linear shapes:
 line segment,
 ray,
 and straight line.
 The ray and the line are automatically clipped by the axis bounds.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Standard
The following sections describe the functions related to each geometry family.
\end_layout

\begin_layout Subsection
Straight lines
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "subsec:Straight-Line"

\end_inset


\end_layout

\begin_layout Standard
Straight lines are infinite in each direction.
 They are represented by a 1-by-4 row vector concatenating the origin and the direction vector:
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

LINE = [X0 Y0  DX DY];
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
lines2d 
\end_layout

\begin_layout Standard
Description of functions operating on planar lines.
\end_layout

\begin_layout Minisec
createLine
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createLine
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a straight line from 2 points,
 or from other inputs.
\end_layout

\begin_layout Minisec
fitLine
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fitLine
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fitting!line
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Fits a straight line to a set of points.
\end_layout

\begin_layout Minisec
medianLine
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
medianLine
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a median line between two points.
\end_layout

\begin_layout Minisec
cartesianLine
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
cartesianLine
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a straight line from cartesian equation coefficients.
\end_layout

\begin_layout Minisec
orthogonalLine
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
orthogonalLine
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a line orthogonal to another one through a point.
\end_layout

\begin_layout Minisec
parallelLine
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
parallelLine
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a line parallel to another one.
\end_layout

\begin_layout Minisec
intersectLines
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectLines
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns all intersection points of N lines in 2D.
\end_layout

\begin_layout Minisec
lineAngle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
lineAngle
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angle!line
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes angle between two straight lines.
\end_layout

\begin_layout Minisec
linePoint
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
linePoint
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a point at a given position on a line.
\end_layout

\begin_layout Minisec
linePosition
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
linePosition
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Position of a point on a line.
\end_layout

\begin_layout Minisec
clipLine
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipLine
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipping!line
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Clips a line with a box.
\end_layout

\begin_layout Minisec
reverseLine
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
reverseLine
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns same line but with opposite orientation.
\end_layout

\begin_layout Minisec
transformLine
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
transformLine
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Transforms a line with an affine transform.
\end_layout

\begin_layout Minisec
drawLine
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawLine
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a straight line clipped by the current axis.
\end_layout

\begin_layout Subsection
Edges (line segments between 2 points)
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "subsec:Line-Segment"

\end_inset


\end_layout

\begin_layout Standard
Line segments correspond to the set of points between two extremity points.
 The term 
\begin_inset Quotes eld
\end_inset

edge
\begin_inset Quotes erd
\end_inset

 is used interchangeably with line segment.
 They are represented by a 1-by-4 row vector concatenating the coordinates of the first and last points:
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

EDGE = [X1 Y1  X2 Y2];
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
edges2d 
\end_layout

\begin_layout Standard
Description of functions operating on planar edges.
\end_layout

\begin_layout Minisec
createEdge
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createEdge
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates an edge between two points,
 or from a line.
\end_layout

\begin_layout Minisec
edgeToLine
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
edgeToLine
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts an edge to a straight line.
\end_layout

\begin_layout Minisec
edgeAngle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
edgeAngle
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angle!line segment
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Returns the horizontal angle of edge.
\end_layout

\begin_layout Minisec
edgeLength
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
edgeLength
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns the length of an edge.
\end_layout

\begin_layout Minisec
parallelEdge
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
parallelEdge
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Create a new edge parallel to another edge.
\end_layout

\begin_layout Minisec
midPoint
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
midPoint
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the middle point of two points,
 or the middle point of an edge,
 depending on size of input argument(s).
\end_layout

\begin_layout Minisec
edgePoint
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
edgePoint
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a point at a given position on an edge.
\end_layout

\begin_layout Minisec
edgePosition
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
edgePosition
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns the position of a point on an edge.
\end_layout

\begin_layout Minisec
clipEdge
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipEdge
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipping!line segment
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Clips an edge with a rectangular box.
\end_layout

\begin_layout Minisec
reverseEdge
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
reverseEdge
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Interverts the source and target vertices of edge.
\end_layout

\begin_layout Minisec
intersectEdges
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectEdges
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns all intersections between two sets of edges.
\end_layout

\begin_layout Minisec
intersectLineEdge
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectLineEdge
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns the intersection between a line and an edge.
\end_layout

\begin_layout Minisec
transformEdge
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
transformEdge
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Transforms an edge with an affine transform.
\end_layout

\begin_layout Minisec
edgeToPolyline
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
edgeToPolyline
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts an edge to a polyline with a given number of segments.
\end_layout

\begin_layout Minisec
drawEdge
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawEdge
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws an edge given by 2 points.
\end_layout

\begin_layout Subsection
Centered Edges
\end_layout

\begin_layout Standard
Centered edges have same shape as edges (line segments),
 but are represented in a different way.
 They are defined by the coordinates of edge center,
 the length of the edge,
 and the orientation (in degrees):
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

CEDG = [XC YC  L  ORI];
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
centeredEdgeToEdge
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
centeredEdgeToEdge
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts a centered edge to a two-points edge.
\end_layout

\begin_layout Minisec
drawCenteredEdge
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawCenteredEdge
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws an edge centered on a point.
\end_layout

\begin_layout Subsection
Rays
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "subsec:Ray"

\end_inset


\end_layout

\begin_layout Standard
Rays emanate from a point,
 and are unbounded in one direction.
 They are represented the same way as (straight) lines,
 by a 1-by-4 row vector concatenating the origin and the direction vector:
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

RAY = [X0 Y0  DX DY];
\end_layout

\end_inset


\end_layout

\begin_layout Standard
The difference of behavior is managed within the functions.
\end_layout

\begin_layout Minisec
rays2d 
\end_layout

\begin_layout Standard
Description of functions operating on planar rays.
\end_layout

\begin_layout Minisec
createRay
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createRay
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a ray (half-line),
 from various inputs.
\end_layout

\begin_layout Minisec
bisector
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
bisector
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns the bisector of two lines,
 or 3 points.
\end_layout

\begin_layout Minisec
clipRay
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipRay
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Clips a ray with a box.
\end_layout

\begin_layout Minisec
drawRay
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawRay
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a ray on the current axis.
\end_layout

\begin_layout Subsection
Relations between points and lines
\end_layout

\begin_layout Standard
These functions determine relative position of a point (or an array of points) and a linear shape.
\end_layout

\begin_layout Minisec
distancePointEdge
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distancePointEdge
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Minimum distance between a point and an edge.
\end_layout

\begin_layout Minisec
distancePointLine
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distancePointLine
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distance!point to line
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Minimum distance between a point and a line.
\end_layout

\begin_layout Minisec
projPointOnLine
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
projPointOnLine
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
projection!on line
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Projects of a point orthogonally onto a line.
\end_layout

\begin_layout Minisec
isPointOnLine
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isPointOnLine
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Tests if a point belongs to a line.
\end_layout

\begin_layout Minisec
isPointOnEdge
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isPointOnEdge
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Tests if a point belongs to an edge.
\end_layout

\begin_layout Minisec
isPointOnRay
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isPointOnRay
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Tests if a point belongs to a ray.
\end_layout

\begin_layout Minisec
isLeftOriented
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isLeftOriented
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Tests if a point is on the left side of a line.
\end_layout

\begin_layout Subsection
Angles
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "subsec:Angles"

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angle
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Angles are expressed in radians,
 counter-clockwise,
 with 
\begin_inset Formula $0$
\end_inset

 corresponding to the horizontal direction.
 Many functions consider angles within the 
\begin_inset Formula $[0;2\pi)$
\end_inset

 domain.
 Representation of geometric shapes usually consider angles in degrees,
 as this is often more intuitive.
\end_layout

\begin_layout Minisec
angles2d 
\end_layout

\begin_layout Standard
Description of functions for manipulating angles.
\end_layout

\begin_layout Minisec
normalizeAngle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
normalizeAngle
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Normalizes an angle value within the 
\begin_inset Formula $[0;2\pi)$
\end_inset

 domain.
\end_layout

\begin_layout Minisec
angleAbsDiff
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angleAbsDiff
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Absolute difference between two angles.
\end_layout

\begin_layout Minisec
angleDiff
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angleDiff
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Difference between two angles.
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Conic curves
\end_layout

\begin_layout Standard
Conic curves are smooth curves that encompass circles,
 ellipses,
 and parabola.
 This section also describe management of conic curve arcs (section
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "subsec:Circle-Arcs"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
 
\end_layout

\begin_layout Subsection
Circles
\end_layout

\begin_layout Standard
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
circle
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Several function operate on circles.
 Circles are represented by a 1-by-3 array [xc yc r],
 where xc and yc denote the circle center and r denotes the circle radius.
 Figure 
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Circle-Demo"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

 presents the results of the computation obtained in the following script.
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

% construction of circum circle to three points
\end_layout

\begin_layout Plain Layout

pA = [30 20];
 pB = [80 40];
 pC = [20 70];
\end_layout

\begin_layout Plain Layout

circ = circumCircle(pA,
 pB,
 pC);
\end_layout

\begin_layout Plain Layout

% polygon discretisation
\end_layout

\begin_layout Plain Layout

poly = circleToPolygon(circ,
 12);
\end_layout

\begin_layout Plain Layout

% intersection with a line (given as origin + direction)
\end_layout

\begin_layout Plain Layout

line = [60 70  5 2];
\end_layout

\begin_layout Plain Layout

inters = intersectLineCircle(line,
 circ);
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/geom2d/circle_demo.png
	lyxscale 50
	width 60text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Circle-Demo"

\end_inset

Construction of a circle from 3 points (blue curve),
 discretization into a polygon (green curve),
 and computation of its intersections with a straight line (black dots).
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Subsubsection*
Creation functions
\end_layout

\begin_layout Minisec
circles2d 
\end_layout

\begin_layout Standard
Description of functions operating on circles and circle arcs.
\end_layout

\begin_layout Minisec
createCircle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createCircle
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a circle from 2 or 3 points.
\end_layout

\begin_layout Minisec
createDirectedCircle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createDirectedCircle
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a directed circle.
\end_layout

\begin_layout Minisec
enclosingCircle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
enclosingCircle
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Finds the minimum circle enclosing a set of points.
\end_layout

\begin_layout Minisec
circumCircle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
circumCircle
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Circumscribed circle of three points.
\end_layout

\begin_layout Subsubsection*
Processing functions
\end_layout

\begin_layout Minisec
intersectCircles
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectCircles
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the intersection points of two circles.
\end_layout

\begin_layout Minisec
intersectLineCircle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectLineCircle
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Compute the intersection point(s) of a line and a circle.
\end_layout

\begin_layout Minisec
circleToPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
circleToPolygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Converts a circle into a series of points.
\end_layout

\begin_layout Minisec
isPointInCircle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isPointInCircle
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Tests if a point is located inside a given circle.
\end_layout

\begin_layout Minisec
isPointOnCircle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isPointOnCircle
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Tests if a point is located on a given circle.
\end_layout

\begin_layout Minisec
radicalAxis
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
radicalAxis
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the radical axis (or radical line) of 2 circles
\end_layout

\begin_layout Subsubsection*
Display functions
\end_layout

\begin_layout Minisec
drawCircle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawCircle
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a circle on the current axis.
\end_layout

\begin_layout Standard
\begin_inset Newpage clearpage
\end_inset


\end_layout

\begin_layout Subsection
Ellipses
\end_layout

\begin_layout Standard
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
ellipse
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Ellipses are represented by a 1-by-5 array [xc yc a b theta],
 where xc and yc denote the ellipse center,
 a and b denote the lengths of the semi axes,
 and theta denotes the orientation of the first principal axis.
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

ELLI = [XC YC  A B  THETA];
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Note Note
status open

\begin_layout Plain Layout
TODO:
 figure
\end_layout

\end_inset


\end_layout

\begin_layout Subsubsection*
Creation functions
\end_layout

\begin_layout Minisec
ellipses2d 
\end_layout

\begin_layout Standard
Description of functions operating on ellipses.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status collapsed

\begin_layout Plain Layout
\align center
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/geom2d/fitEllipseToPoints.png
	width 6cm

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Fit ellipse to points.
\end_layout

\end_inset


\end_layout

\end_inset


\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status collapsed

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/geom2d/pointSetEquivalentEllipse.png
	width 6cm

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Equivalent inertia ellipse.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Creation-of-Ellipses"

\end_inset

Creation of ellipses.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Minisec
createEllipse
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createEllipse
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Create an ellipse,
 from various input types.
\end_layout

\begin_layout Minisec
fitEllipse
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fitEllipse
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fitting!ellipse
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Fits an ellipse to a set of 2D points,
 using least-square method based on 
\begin_inset CommandInset citation
LatexCommand citet
key "Fitzgibbon_1999_PAMI"
literal "false"

\end_inset

 (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Creation-of-Ellipses"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-A).
\end_layout

\begin_layout Minisec
equivalentEllipse
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
equivalentEllipse
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
moments!points
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the equivalent ellipse with same moments up to the second order as a set of points (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Creation-of-Ellipses"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-B).
\end_layout

\begin_layout Subsubsection*
Computation functions
\end_layout

\begin_layout Minisec
isPointInEllipse
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isPointInEllipse
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Checks if a point is located inside a given ellipse.
\end_layout

\begin_layout Minisec
distancePointEllipse
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distancePointEllipse
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the Euclidean distance between a point (or a point set) and an ellipse (see Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:ProjPoint-On-Ellipse"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Minisec
projPointOnEllipse
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
projPointOnEllipse
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
projection!on ellipse
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the (orthogonal) projection of a point (or a point set) onto an ellipse (see Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:ProjPoint-On-Ellipse"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

elli = [50 50  40 20  30];
                         % reference ellipse
\end_layout

\begin_layout Plain Layout

figure;
 hold on;
 axis equal;
 axis([0 100 0 100]);
  % create display
\end_layout

\begin_layout Plain Layout

drawEllipse(elli,
 'LineWidth',
 2,
 'Color',
 'k');
\end_layout

\begin_layout Plain Layout

pts = [90 50 ;
 50 90 ;
 10 70];
\end_layout

\begin_layout Plain Layout

drawPoint(pts,
 'bo');
                              % draw points
\end_layout

\begin_layout Plain Layout

proj = projPointOnEllipse(pts,
 elli);
              % compute projections
\end_layout

\begin_layout Plain Layout

drawPoint(proj,
 'ko');
\end_layout

\begin_layout Plain Layout

drawEdge([pts proj],
 'b');
                         % draw connection between points
\end_layout

\begin_layout Plain Layout

dists = distancePointEllipse(pts,
 elli);
           % compute distances to ellipse
\end_layout

\begin_layout Plain Layout

mid = midPoint(pts,
 proj);	        		     % display distances as labels
\end_layout

\begin_layout Plain Layout

drawLabels(mid + [1 2],
 dists);
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/geom2d/projPointOnEllipse.png
	width 6cm

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:ProjPoint-On-Ellipse"

\end_inset

Distance from point to ellipse,
 and orthogonal projection onto ellipse.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Minisec
ellipseToPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
ellipseToPolygon
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts an ellipse into a series of points.
\end_layout

\begin_layout Minisec
ellipsePoint
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
ellipsePoint
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the coordinates of a point on an ellipse from its parametric position (between 0 and 
\begin_inset Formula $2\pi$
\end_inset

).
\end_layout

\begin_layout Minisec
\begin_inset CommandInset label
LatexCommand label
name "fun:transformEllipse"

\end_inset

transformEllipse
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
transformEllipse
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Applies an affine transform to an ellipse and returns the parameters of the transformed ellipse.
\end_layout

\begin_layout Subsubsection*
Description functions
\end_layout

\begin_layout Minisec
ellipsePerimeter
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
ellipsePerimeter
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the perimeter of an ellipse using numerical integration.
\end_layout

\begin_layout Minisec
ellipseArea
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
ellipseArea
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the area of an ellipse,
 as the product of the semi-axis lengths multiplied by 
\begin_inset Formula $\pi$
\end_inset

.
 
\end_layout

\begin_layout Minisec
ellipseCartesianCoefficients
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
ellipseCartesianCoefficients
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the coefficients of the cartesian equation of an ellipse.
 Can be used for computing result of affine transform applied on an ellipse.
\end_layout

\begin_layout Subsubsection*
Drawing functions
\end_layout

\begin_layout Minisec
drawEllipse
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawEllipse
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draws an ellipse on the current axis.
\end_layout

\begin_layout Minisec
drawEllipseAxes
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawEllipseAxes
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draws the main axes of an ellipse as line segments.
\end_layout

\begin_layout Subsubsection*
Application for statistical display
\end_layout

\begin_layout Standard
A small example for working with ellipses is given in following script.
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

load fisherIris;
\end_layout

\begin_layout Plain Layout

figure;
 hold on;
 set(gca,
 'fontsize',
 14);
\end_layout

\begin_layout Plain Layout

colors = {'b',
 'g',
 'm'};
\end_layout

\begin_layout Plain Layout

hi = zeros(1,
 3);
\end_layout

\begin_layout Plain Layout

for i = 1:3
\end_layout

\begin_layout Plain Layout

    pts = meas((1:50)+(i-1) * 50,
 3:4);
\end_layout

\begin_layout Plain Layout

    hi(i) = drawPoint(pts,
 'Marker',
 'o',
 'Color',
 colors{i},
 'MarkerFaceColor',
 colors{i});
\end_layout

\begin_layout Plain Layout

    drawEllipse(equivalentEllipse(pts),
 'Color',
 colors{i},
 'LineWidth',
 2);
\end_layout

\begin_layout Plain Layout

end
\end_layout

\begin_layout Plain Layout

legend(hi,
 species([1 51 101]),
 'Location',
 'NorthWest');
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/equivalentEllipse_demo.png
	width 50text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Computation of equivalent ellipses to represent variance of groups within Fisher iris dataset.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Subsection
Circle and ellipse arcs
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "subsec:Circle-Arcs"

\end_inset


\end_layout

\begin_layout Standard
Circle arcs are defined with a 
\begin_inset Formula $1\times5$
\end_inset

 row vector containing center and radius of supprting circle,
 angle of first point (in degrees) and angular extent (in degrees).
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

CA = [CX CY R  TH0 DTH];
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
circleArcToPolyline
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
circleArcToPolyline
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts a circle arc into a series of points.
\end_layout

\begin_layout Minisec
drawCircleArc
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawCircleArc
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a circle arc on the current axis.
\end_layout

\begin_layout Minisec
drawEllipseArc
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawEllipseArc
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws an ellipse arc on the current axis.
\end_layout

\begin_layout Subsection
Parabola
\end_layout

\begin_layout Standard
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
parabola
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Apart circles and ellipses,
 parabola can be drawn with MatGeom.
\end_layout

\begin_layout Minisec
drawParabola
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawParabola
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a parabola on the current axis.
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Other Curves 
\end_layout

\begin_layout Subsection
Splines
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout

\family roman
\series medium
\shape up
\size normal
\emph off
\nospellcheck off
\bar no
\strikeout off
\xout off
\uuline off
\uwave off
\noun off
\color none
spline
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Spline curves are a convenient way to represent a large family of curves with a few number control points.
\end_layout

\begin_layout Minisec
cubicBezierToPolyline
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
cubicBezierToPolyline
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes an approximated polyline from Bezier curve control points,
 specifying the number of vertices.
\end_layout

\begin_layout Minisec
drawBezierCurve
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawBezierCurve
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a cubic bezier curve defined by 4 control points (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Bezier-Curve"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/demoBezierCurve.png
	lyxscale 50
	width 60text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Bezier-Curve"

\end_inset

Bezier Curve through four points
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Simple polygons
\end_layout

\begin_layout Standard
This sections concerns simple polygonal shapes with a fixed number of vertices,
 such as triangles,
 rectangles,
 and boxes.
 More general polygons (i.e.
 defined from an arbitrary number of vertices) are described in chapter
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "chap:polygons2d"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status collapsed

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/geom2d/box_def.png
	width 30text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Box.
\end_layout

\end_inset


\end_layout

\end_inset


\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status collapsed

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/geom2d/rectangle_def.png
	width 30text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Rectangle.
\end_layout

\end_inset


\end_layout

\end_inset


\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status collapsed

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/geom2d/orientedBox_def.png
	width 30text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Oriented box
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Boxes-And-Rectangles"

\end_inset

Representation of boxes,
 rectangles,
 and oriented boxes.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Standard
For rectangular shapes,
 several representations may be considered.
 The following conventions are considered within the MatGeom library (See also Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Boxes-And-Rectangles"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

):
\end_layout

\begin_layout Description
boxes are defined from the extent along each dimension.
 Functions operating on boxes are described in section 
\begin_inset CommandInset ref
LatexCommand ref
reference "subsec:Boxes"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Description
(axis-aligned)
\begin_inset space ~
\end_inset

rectangles are defined from the lower-left corner and the dimensions.
 Functions operating on rectangles are described in section 
\begin_inset CommandInset ref
LatexCommand ref
reference "subsec:Rectangles"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Description
oriented
\begin_inset space ~
\end_inset

boxes are also defined based on their dimensions,
 but also takes into account the orientation (angle with horizontal).
 The reference point is the center of the rectangle instead of its corner.
 Functions operating on oriented boxes are described in section 
\begin_inset CommandInset ref
LatexCommand ref
reference "subsec:Oriented-Boxes"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Subsection
Boxes
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "subsec:Boxes"

\end_inset


\end_layout

\begin_layout Standard
Boxes are used to represent bounds of geometric shapes.
 They are represented by a four-element row vector containing the minimum and maximum coordinate along each dimension (Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Boxes-And-Rectangles"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-a).
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

box = [xmin xmax ymin ymax];
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
boxes2d 
\end_layout

\begin_layout Standard
Description of functions operating on bounding boxes.
\end_layout

\begin_layout Minisec
intersectBoxes
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectBoxes
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the intersection of two bounding boxes,
 as the largest box contained within the two input boxes.
 
\end_layout

\begin_layout Minisec
mergeBoxes
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
mergeBoxes
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Merges two boxes,
 by computing their greatest extent.
 The result corresponds to the smallest box containing the two input boxes.
\end_layout

\begin_layout Minisec
randomPointInBox
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
randomPointInBox
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Generates random point within a box.
\end_layout

\begin_layout Minisec
boxToRect
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
boxToRect
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts box data to rectangle data.
\end_layout

\begin_layout Minisec
boxToPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
boxToPolygon
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts a bounding box to a rectangular polygon.
\end_layout

\begin_layout Minisec
drawBox
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawBox
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a box defined by coordinate extents.
\end_layout

\begin_layout Subsection
Rectangles
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "subsec:Rectangles"

\end_inset


\end_layout

\begin_layout Standard
A rectangle is represented by the coordinates of the lower-left vertex,
 and by the dimensions of the rectangle (Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Boxes-And-Rectangles"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-b).
 
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

rect = [x0 y0 sizeX sizeY];
\end_layout

\end_inset


\end_layout

\begin_layout Standard
By default,
 the edges of the rectangle are aligned with the main axes.
 Some functions allow to specify a fifth parameter specifying the orientation of the rectangle (in degrees).
 The resulting shape is obtained by rotating the rectangle around its lower-left corner by the specified angle.
\end_layout

\begin_layout Minisec
rectToPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
rectToPolygon
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts a rectangle into a polygon (set of vertices).
\end_layout

\begin_layout Minisec
rectToBox
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
rectToBox
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts rectangle data to box data.
\end_layout

\begin_layout Minisec
drawRect
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawRect
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws rectangle on the current axis.
\end_layout

\begin_layout Subsection
Oriented boxes
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "subsec:Oriented-Boxes"

\end_inset


\end_layout

\begin_layout Standard
In some cases,
 it may be convenient to take into orientation of the box.
 For example,
 minimum-width bounding boxes are oriented.
 An oriented box is represented by the coordinates of the center,
 the dimensions of the rectangle,
 and the orientation of the box (Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Boxes-And-Rectangles"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-c).
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

obox = [xCenter yCenter length width theta];
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
orientedBox
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
orientedBox
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the minimum-width oriented bounding box of a set of points.
\end_layout

\begin_layout Minisec
orientedBoxToPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
orientedBoxToPolygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Converts an oriented box to a polygon (set of vertices).
\end_layout

\begin_layout Minisec
drawOrientedBox
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawOrientedBox
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws centered oriented box.
\end_layout

\begin_layout Subsection
Triangles
\end_layout

\begin_layout Standard
Utility functions are also provided for working on triangles.
 Triangles are simply represented by a 
\begin_inset Formula $3\times2$
\end_inset

 numeric array containing the coordinates of the three vertices.
\end_layout

\begin_layout Minisec
isPointInTriangle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isPointInTriangle
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Tests if a point is located inside a triangle.
\end_layout

\begin_layout Minisec
triangleArea
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
triangleArea
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the signed area of a triangle.
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Geometric transforms
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "sec:Transforms"

\end_inset


\end_layout

\begin_layout Standard
The MatGeom library contains various functions for manipulation of geometric transforms.
 Most of them consider affine transforms in the plane,
 that can be represented by a 3-by-3 matrix in homogeneous coordinates:
\begin_inset Formula 
\begin{align}
\left(\begin{array}{c}
x'\\
y'\\
1
\end{array}\right) & =\left(\begin{array}{ccc}
m_{xx} & m_{xy} & t_{x}\\
m_{yx} & m_{yy} & t_{y}\\
0 & 0 & 1
\end{array}\right)\left(\begin{array}{c}
x\\
y\\
1
\end{array}\right)\label{eq:AffineTransform2D}
\end{align}

\end_inset

where the 
\begin_inset Formula $m_{ij}$
\end_inset

 correspond to the linear part of the transform (rotations,
 scaling,
 shear...) and the 
\begin_inset Formula $t_{i}$
\end_inset

 correspond to the translation part.
 
\end_layout

\begin_layout Standard
Note that in MatGeom,
 while points are represented as 
\begin_inset Formula $1\times2$
\end_inset

 row vectors (or 
\begin_inset Formula $n_{p}\times2$
\end_inset

 arrays),
 the transform is represented as the 
\begin_inset Formula $3\times3$
\end_inset

 matrix in eq.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "eq:AffineTransform2D"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
 Applying a transform to a point or a point array requires transposing one of the arrays,
 and taking care of conversion between cartesian and homogeneous coordinates.
 The transformPoint function (as well as related ones) automatically performs the necessary conversions.
\end_layout

\begin_layout Subsection
Creation of basic transforms
\end_layout

\begin_layout Standard
This sections list the functions that creates classical affine transforms (rotations,
 translations...).
\end_layout

\begin_layout Minisec
transforms2d 
\end_layout

\begin_layout Standard
Description of functions operating on transforms.
\end_layout

\begin_layout Minisec
createTranslation
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createTranslation
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates the 3-by-3 matrix of a translation,
 given the components of the translation vector.
 If the translation vector is given by 
\begin_inset Formula $\mathbf{v}$
\end_inset

,
 the resulting matrix is given by:
\begin_inset Formula 
\[
T_{\mathbf{v}}=\left(\begin{array}{ccc}
1 & 0 & v_{x}\\
0 & 1 & v_{y}\\
0 & 0 & 1
\end{array}\right)
\]

\end_inset

Example:
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

>> createTranslation([5 4])
\end_layout

\begin_layout Plain Layout

ans =
\end_layout

\begin_layout Plain Layout

     1     0     5
\end_layout

\begin_layout Plain Layout

     0     1     4
\end_layout

\begin_layout Plain Layout

     0     0     1
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
createRotation
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createRotation
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates the 3-by-3 matrix of a rotation by an angle 
\begin_inset Formula $\theta$
\end_inset

,
 corresponding to the following transform matrix:
\begin_inset Formula 
\[
R_{\theta}=\left(\begin{array}{ccc}
\cos\theta & -\sin\theta & 0\\
\sin\theta & \cos\theta & 0\\
0 & 0 & 1
\end{array}\right)
\]

\end_inset

Example:
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

>> createRotation(pi/6)
\end_layout

\begin_layout Plain Layout

ans =
\end_layout

\begin_layout Plain Layout

    0.8660   -0.5000         0
\end_layout

\begin_layout Plain Layout

    0.5000    0.8660         0
\end_layout

\begin_layout Plain Layout

         0         0    1.0000
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
createRotation90
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createRotation90
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Matrix of a rotation around the origin by multiples of 90 degrees.
 Matrix components values are therefore only 
\begin_inset Formula $0$
\end_inset

,
 
\begin_inset Formula $+1$
\end_inset

 or 
\begin_inset Formula $-1$
\end_inset

.
 Example:
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

>> createRotation90(1)
\end_layout

\begin_layout Plain Layout

ans =
\end_layout

\begin_layout Plain Layout

     0    -1     0
\end_layout

\begin_layout Plain Layout

     1     0     0
\end_layout

\begin_layout Plain Layout

     0     0     1
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
createScaling
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createScaling
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates the 3-by-3 matrix of a scaling in 2 dimensions.
\end_layout

\begin_layout Standard
\begin_inset Formula 
\[
R_{\theta}=\left(\begin{array}{ccc}
s_{x} & 0 & 0\\
0 & s_{y} & 0\\
0 & 0 & 1
\end{array}\right)
\]

\end_inset


\end_layout

\begin_layout Minisec
createHomothecy
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createHomothecy
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates the the 3-by-3 matrix of an homothetic transform.
\end_layout

\begin_layout Minisec
createBasisTransform
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createBasisTransform
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes matrix for transforming a basis into another basis.
\end_layout

\begin_layout Minisec
createLineReflection
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createLineReflection
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the the 3-by-3 transformation matrix corresponding to a line reflection.
\end_layout

\begin_layout Subsection
Fit transforms
\end_layout

\begin_layout Standard
Some functions also allow computing the geometric transform that matches two point sets.
\end_layout

\begin_layout Minisec
fitAffineTransform2d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fitAffineTransform2d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Fits an affine transform using two point sets.
\end_layout

\begin_layout Minisec
registerICP
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
registerICP
\end_layout

\end_inset

 
\begin_inset CommandInset label
LatexCommand label
name "fun:registerICP"

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
registration
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Fits an affine transform between two point sets by using Iterative Closest Point (ICP) algorithm 
\begin_inset CommandInset citation
LatexCommand citep
key "Besl_1992_PAMI"
literal "false"

\end_inset

.
 See also the registerPoints3d_icp function (section
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fun:registerPoints3d_icp"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Subsection
Polynomial transforms
\end_layout

\begin_layout Standard
A polynomial transform is represented by a row vector containing the coefficients applied to each monomial,
 in increasing order of degree and starting with largest degree of 
\begin_inset Formula $x$
\end_inset

 coordinate.
 For example,
 a second order transform is represented by the following vector:
\begin_inset Formula 
\[
[a_{00},b_{00},a_{10},b_{10},a_{01},b_{01},a_{20},b_{20},a_{11},b_{11},a_{02},b_{02}]
\]

\end_inset

,
 leading to the transform:
\begin_inset Formula 
\begin{align*}
\left(\begin{array}{c}
x'\\
y'
\end{array}\right) & =\left(\begin{array}{cccccc}
a_{00} & a_{10} & a_{01} & a_{20} & a_{11} & a_{02}\\
b_{00} & b_{10} & b_{01} & b_{20} & b_{11} & b_{02}
\end{array}\right)\cdot\left(\begin{array}{c}
1\\
x\\
y\\
x^{2}\\
xy\\
y^{2}
\end{array}\right)
\end{align*}

\end_inset


\end_layout

\begin_layout Minisec
polynomialTransform2d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polynomialTransform2d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Applies a polynomial transform to a set of points.
 
\end_layout

\begin_layout Minisec
fitPolynomialTransform2d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fitPolynomialTransform2d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the coefficients of the polynomial transform that matches two point sets.
 Note that using large degrees may result in degenerated transforms.
\end_layout

\begin_layout Section
Grids and tessellations
\end_layout

\begin_layout Standard
This sections presents functions used to generate less common geometric objects such as grids.
\end_layout

\begin_layout Minisec
drawGrid
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout

\family roman
\series medium
\shape up
\size normal
\emph off
\nospellcheck off
\bar no
\strikeout off
\xout off
\uuline off
\uwave off
\noun off
\color none
drawGrid
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Display an isothetic grid (with edges parallel to main axes) defined by spacing of vertices.
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

lx = 5:5:35;
 ly = 15:5:40;
\end_layout

\begin_layout Plain Layout

figure;
 hold on;
 axis equal;
 axis([0 50 0 50]);
\end_layout

\begin_layout Plain Layout

drawGrid(lx,
 ly,
 'k');
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
squareGrid
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
squareGrid
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Generates equally spaces points in plane.
\end_layout

\begin_layout Minisec
hexagonalGrid
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
hexagonalGrid
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Generates hexagonal grid of points in the plane.
\end_layout

\begin_layout Minisec
triangleGrid
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
triangleGrid
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Generates triangular grid of points in the plane.
\end_layout

\begin_layout Minisec
crackPattern
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
crackPattern
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a (bounded) crack pattern tessellation.
\end_layout

\begin_layout Minisec
crackPattern2
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
crackPattern2
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a (bounded) crack pattern tessellation.
\end_layout

\begin_layout Chapter
Module polygons2d
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "chap:polygons2d"

\end_inset


\end_layout

\begin_layout Standard
The 
\series bold
polygons2d
\series default
 module contains functions operating on shapes composed of a vertex list,
 like polygons or polylines.
 
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
minitoc
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Definitions
\end_layout

\begin_layout Standard
A 
\series bold
polyline
\series default

\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polyline
\end_layout

\end_inset

 is the curve defined by a series of vertices (Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Polyline-and-Polygon"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-a).
 A polyline can be either 
\series bold
closed
\series default
 or 
\series bold
open
\series default
,
 depending on whether the last vertex is connected to the first one or not.
 Open polylines are also called 
\begin_inset Quotes eld
\end_inset


\series bold
line strings
\series default

\begin_inset Quotes erd
\end_inset

,
 and closed polylines may be called 
\begin_inset Quotes eld
\end_inset


\series bold
linear rings
\series default

\begin_inset Quotes erd
\end_inset

.
 The openness can be given as an option is some functions in the module.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status collapsed

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/polygons2d/def/polyline_vertices.png
	special height=4cm

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Polyline
\end_layout

\end_inset


\end_layout

\end_inset


\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status collapsed

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/polygons2d/def/polygon_vertices_annot.png
	special height=4cm

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Polygon
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Polyline-and-Polygon"

\end_inset

Example of polyline and polygon.
 (a) An open polyline defined by a series of vertices.
 (b) The corresponding (counter-clockwise oriented) polygon,
 with interior coloured in light blue.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Standard
A
\series bold
 polygon
\series default

\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygon
\end_layout

\end_inset

 is the planar domain delimited by a closed polyline (Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Polyline-and-Polygon"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-a).
 We sometimes want to consider 
\begin_inset Quotes eld
\end_inset


\series bold
multiple polygons
\series default

\begin_inset Quotes erd
\end_inset

 (or complex polygons),
 whose boundary is composed of several disjoint domains (Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand vpageref
reference "fig:Multiple-Polygon"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
 The domain enclosed by a single closed polyline (or linear ring) is called 
\begin_inset Quotes eld
\end_inset


\series bold
simple polygon
\series default

\begin_inset Quotes erd
\end_inset

.
 
\end_layout

\begin_layout Standard
Within MatGeom,
 a 
\series bold
curve
\series default
 has to be understood as a polyline with many vertices,
 such that the polyline can be considered as a discrete approximation of a smooth curve.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/polygons2d/def/multiple_polygon.png
	width 75text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Multiple-Polygon"

\end_inset

Example of a multiple polygon.
 The polygon is composed of three connected components,
 one of them presents a hole.
 The boundary is composed of four linear rings.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Section
Data representation
\end_layout

\begin_layout Standard
A simple polygon or polyline is represented by a N-by-2 array,
 each row of the array representing the coordinates of a vertex.
 Simple polygons are assumed to be closed,
 so there is no need to repeat the first vertex at the end.
 
\end_layout

\begin_layout Standard
As both polygons and polylines can be represented by a list of vertex coordinates,
 some functions also consider the vertex list itself.
 Such functions are prefixed by 'pointSet'.
 Also,
 many functions prefixed by 'polygon' or 'polyline' works also on the other type of shape.
\end_layout

\begin_layout Standard
For multiple polygons,
 the different connected boundaries are separated by a row [NaN NaN].
 For some functions,
 the orientation of the polygon can be relevant:
 CCW stands for 'Counter-Clockwise' (positive orientation),
 CW stands for 'Clockwise'.
\end_layout

\begin_layout Standard
Example:
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

% Simple polygon (square shape)
\end_layout

\begin_layout Plain Layout

poly1 = [1 1;
 2 1;
 2 2;
 1 2];
\end_layout

\begin_layout Plain Layout

figure;
 hold on;
 axis equal;
 axis([0 5 0 5]);
\end_layout

\begin_layout Plain Layout

drawPolygon(poly1);
\end_layout

\begin_layout Plain Layout

% Multiple polygon:
\end_layout

\begin_layout Plain Layout

poly2 = [10 10;40 10;
 40 40;10 40;NaN NaN;20 20;20 30;30 30;30 20];
\end_layout

\begin_layout Plain Layout

figure;
 hold on;
 axis equal;
 axis([0 50 0 50]);
\end_layout

\begin_layout Plain Layout

fillPolygon(poly2,
 'y');
 drawPolygon(poly2,
 'b');
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Note that Matlab also provides the 
\begin_inset Quotes eld
\end_inset

polyshape
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polyshape
\end_layout

\end_inset


\begin_inset Quotes erd
\end_inset

 class,
 that gives access to many features,
 and is used internally by some functions of MatGeom.
\end_layout

\begin_layout Subsection
Parametrization
\end_layout

\begin_layout Standard
Parametrization associates a position to each point of a polyline,
 or of a polygon boundary.
 Polylines and polygons are parametrized in the following way:
\end_layout

\begin_layout Itemize
the i-th vertex is located at position i-1
\end_layout

\begin_layout Itemize
points of the i-th edge have positions ranging linearly from i-1 to i
\end_layout

\begin_layout Standard
\begin_inset Note Note
status open

\begin_layout Plain Layout
add figure
\end_layout

\end_inset


\end_layout

\begin_layout Standard
The parametrization domain for an open polyline is from 
\begin_inset Formula $0$
\end_inset

 to 
\begin_inset Formula $N_{v}-1$
\end_inset

,
 and from 
\begin_inset Formula $0$
\end_inset

 to 
\begin_inset Formula $N_{v}$
\end_inset

 for a closed polyline (in the latter case,
 positions 
\begin_inset Formula $0$
\end_inset

 and 
\begin_inset Formula $Nv$
\end_inset

 correspond to the same point).
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Basic operations
\end_layout

\begin_layout Subsection
Basic editing
\end_layout

\begin_layout Standard
These functions allow to extract specific elements or subsets of a polyline or a polygon.
\end_layout

\begin_layout Minisec
polygonEdges
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonEdges
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns the edges of a simple or multiple polygon.
\end_layout

\begin_layout Minisec
polygonLoops
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonLoops
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Divides a possibly self-intersecting polygon into a set of simple loops.
\end_layout

\begin_layout Minisec
splitPolygons
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
splitPolygons
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Converts a NaN separated polygon list to a cell array of polygons.
\end_layout

\begin_layout Minisec
polygonVertices
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonVertices
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Extracts all vertices of a (multi-)polygon.
\end_layout

\begin_layout Minisec
reversePolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
reversePolygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Reverses a polygon,
 by iterating vertices from the end.
\end_layout

\begin_layout Minisec
reversePolyline
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
reversePolyline
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Reverses a polyline,
 by iterating vertices from the end.
\end_layout

\begin_layout Minisec
removeMultipleVertices
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
removeMultipleVertices
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Removes multiple vertices of a polygon or polyline.
\end_layout

\begin_layout Subsection
Parametrization
\end_layout

\begin_layout Standard
The functions described here allow for converting between points on the geometries and their parametric position.
\end_layout

\begin_layout Minisec
polygonPoint
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonPoint
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Extracts a point from a polygon and a position.
\end_layout

\begin_layout Minisec
polylinePoint
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polylinePoint
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Extracts a point from a polyline and a position.
\end_layout

\begin_layout Minisec
polygonSubcurve
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonSubcurve
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Extracts the portion of a polygon located between two positions,
 and returns a polyline.
\end_layout

\begin_layout Minisec
polylineSubcurve
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polylineSubcurve
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Extracts the portion of a polyline located between two positions.
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Subsection
Measures
\end_layout

\begin_layout Standard
Some functions to compute area,
 perimeter,
 or more complex geometric measures on polygons.
\end_layout

\begin_layout Minisec
polylineLength
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polylineLength
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns the length of a polyline given as a list of points.
\end_layout

\begin_layout Minisec
polygonLength
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonLength
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Perimeter of a polygon.
\end_layout

\begin_layout Minisec
polygonBounds
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonBounds
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the bounding box of a polygon.
\end_layout

\begin_layout Minisec
polylineCentroid
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polylineCentroid
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
centroid!polyline
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the centroid of a polygonal curve defined by a series of vertices.
 It is in general different from the vertex-based centroid,
 as obtained by the 
\begin_inset Quotes eld
\end_inset

centroid
\begin_inset Quotes erd
\end_inset

 function.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/polygons2d/polygon_centroids.png
	lyxscale 50
	special height=5cm

\end_inset


\begin_inset Graphics
	filename images/polygons2d/polygons_bounds_ellipse.png
	lyxscale 50
	special height=5cm

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Polygon-Centroids"

\end_inset

Various summary shapes that can be obtained from a polygon:
 centroids,
 bounding box,
 equivalent ellipse.
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\end_layout

\begin_layout Minisec
polygonCentroid
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonCentroid
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
centroid!polygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the centroid (center of mass) of a polygon.
 It is in general different from the vertex-based centroid,
 as obtained by the 
\begin_inset Quotes eld
\end_inset

centroid
\begin_inset Quotes erd
\end_inset

 function,
 and from the centroid of its boundary,
 as obtained by the polylineCentroid function.
\end_layout

\begin_layout Minisec
polygonArea
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonArea
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
area!polygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the signed area of a polygon.
 If the polygon is clock-wise oriented,
 its area is negative.
\end_layout

\begin_layout Minisec
polygonEquivalentEllipse
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonEquivalentEllipse
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
ellipse!polygon equivalent
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the ellipse with the same moments as the polygon.
\end_layout

\begin_layout Minisec
polygonSecondAreaMoments
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonSecondAreaMoments
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
moments!polygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes second-order area moments of a polygon.
\end_layout

\begin_layout Minisec
polygonNormalAngle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonNormalAngle
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angle!polygon normal
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the normal angle at a vertex of the polygon.
\end_layout

\begin_layout Minisec
polygonOuterNormal
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonOuterNormal
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Outer normal vector for a given vertex(ices).
\end_layout

\begin_layout Minisec
distancePolygons
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distancePolygons
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distance!polygons
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the shortest distance between 2 polygons.
\end_layout

\begin_layout Minisec
distancePolygonsNoCross
\end_layout

\begin_layout Standard
Computes the shortest distance between 2 polygons.
\end_layout

\begin_layout Minisec
polygonSignature
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonSignature
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polar signature
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Polar signature of a polygon,
 defined as the polar distance of a polygon point to the origin or to a reference point.
 See the Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Polar-Signature-Polygon"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

 for an example.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/polygons2d/polygonSignature/polygonSignature_rectangle_init.png
	lyxscale 50
	width 45text%

\end_inset


\begin_inset Graphics
	filename images/polygons2d/polygonSignature/polygonSignature_rectangle_signature.png
	lyxscale 50
	width 45text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Polar-Signature-Polygon"

\end_inset

Polar signature of a polygon.
 Example on a rectangle polygon.
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\end_layout

\begin_layout Minisec
signatureToPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
signatureToPolygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Reconstructs a polygon from its polar signature.
\end_layout

\begin_layout Minisec
polygonCurvature
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonCurvature
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
curvature!polygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Estimates the curvature on polygon vertices using polynomial fit.
\end_layout

\begin_layout Section
Clipping and intersections
\end_layout

\begin_layout Standard
These functions allow for clipping polygonal shapes,
 and compute intersections points with linear curves.
\end_layout

\begin_layout Minisec
clipPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipPolygon
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipping!polygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Clips a polygon with a rectangular box.
\end_layout

\begin_layout Minisec
clipPolyline
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipPolyline
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Clips an open polyline with a rectangular box.
\end_layout

\begin_layout Minisec
clipPolygonByLine
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipPolygonByLine
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Clips a polygon with the half-plane defined by a directed line.
\end_layout

\begin_layout Standard
\begin_inset Note Note
status open

\begin_layout Plain Layout
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Intersection points between a line and a polygon + clipping of a polygon.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Minisec
intersectLinePolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectLinePolygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the intersection points between a line and a polygon.
\end_layout

\begin_layout Minisec
intersectLinePolyline
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectLinePolyline
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the intersection points between a line and a polyline.
\end_layout

\begin_layout Minisec
intersectRayPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectRayPolygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the intersection points between a ray and a polygon.
\end_layout

\begin_layout Minisec
intersectEdgePolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectEdgePolygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the intersection point of an edge with a polygon.
\end_layout

\begin_layout Minisec
intersectPolylines
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectPolylines
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Identifies the common points between 2 polylines.
\end_layout

\begin_layout Minisec
polygonSelfIntersections
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonSelfIntersections
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Identifies the self-intersection points of a polygon.
\end_layout

\begin_layout Minisec
polylineSelfIntersections
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polylineSelfIntersections
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Identifies the self-intersection points of a polyline.
\end_layout

\begin_layout Section
Points and polygons
\end_layout

\begin_layout Minisec
isPointOnPolyline
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isPointOnPolyline
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Test if a point belongs to a polyline.
\end_layout

\begin_layout Minisec
isPointInPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isPointInPolygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Test if a point is located inside a polygon.
\end_layout

\begin_layout Minisec
polygonContains
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonContains
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Test if a point is contained in a multiply connected polygon.
\end_layout

\begin_layout Minisec
projPointOnPolyline
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
projPointOnPolyline
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
projection!on polyline
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes position of a point projected on a polyline.
\end_layout

\begin_layout Minisec
projPointOnPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
projPointOnPolygon
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
projection!on polygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes position of a point projected on a polygon.
\end_layout

\begin_layout Minisec
distancePointPolyline
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distancePointPolyline
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distance!point to polyline
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes shortest distance between a point and a polyline.
\end_layout

\begin_layout Minisec
distancePointPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distancePointPolygon
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distance!point to polygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Shortest distance between a point and a polygon.
\end_layout

\begin_layout Section
Smoothing and filtering
\end_layout

\begin_layout Standard
Several functions for the simplification of a polygon or a polyline.
\end_layout

\begin_layout Minisec
resamplePolyline
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
resamplePolyline
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Distributes N points equally spaced on a polyline.
\end_layout

\begin_layout Minisec
resamplePolylineByLength
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
resamplePolylineByLength
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Resamples a polyline with a fixed sampling step.
\end_layout

\begin_layout Minisec
resamplePolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
resamplePolygon
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Distributes N points equally spaced on a polygon.
\end_layout

\begin_layout Minisec
resamplePolygonByLength
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
resamplePolygonByLength
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Resamples a polygon with a fixed sampling step.
\end_layout

\begin_layout Minisec
densifyPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
densifyPolygon
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Adds several points on each edge of the polygon.
\end_layout

\begin_layout Minisec
smoothPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
smoothPolygon
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
smoothing!polygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Smooths a polygon using local averaging,
 see Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Smooth-Simplify-Polygon"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Minisec
simplifyPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
simplifyPolygon
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
simplification!polygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Simplifies a polygon by using Douglas-Peucker algorithm 
\begin_inset CommandInset citation
LatexCommand citep
key "Douglas_Peucker_1973"
literal "false"

\end_inset

,
 see Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Smooth-Simplify-Polygon"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/polygons2d/leafPoly_smoothM31_annot.png
	lyxscale 50
	width 48text%

\end_inset


\begin_inset Graphics
	filename images/polygons2d/leafPoly_simplifiedD5_annot.png
	lyxscale 50
	width 48text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Smooth-Simplify-Polygon"

\end_inset

Smoothing and simplification of a polygon.
 After simplification by a distance equal to 5 (arbitrary unit),
 the number of vertices drops from 2235 (blue curve) to 60 (red line and squares).
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Global processing
\end_layout

\begin_layout Standard
More complex operations on polygons.
\end_layout

\begin_layout Minisec
expandPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
expandPolygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Expands a polygon by a given (signed) distance (Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Polygon-Expansion"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/polygons2d/expandPolygon_OuterAndInner_crop.png
	lyxscale 50
	special height=4.5cm

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Polygon-Expansion"

\end_inset

Expansion (buffering) of a polygon.
 The thick curve corresponds to the original polygon.
 The black and the green curve correspond to outer and inner expansions,
 respectively.
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\end_layout

\begin_layout Minisec
triangulatePolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
triangulatePolygon
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
triangulation!polygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes a triangulation of the polygon (See Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Triangulation-Skeleton"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
 The result is given as a 
\begin_inset Formula $n_{t}\times3$
\end_inset

 array corresponding to triangles,
 and can be displayed using the drawMesh function (section
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fun:drawMesh"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/polygons2d/triangulatePolygon_leafDP5.png
	lyxscale 50
	width 48text%

\end_inset


\begin_inset Graphics
	filename images/polygons2d/demo_polygonSkeleton_leaf.png
	lyxscale 50
	width 48text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Triangulation-Skeleton"

\end_inset

Global operations on a polygon.
 Left:
 triangulation (on a simplified version of the polygon).
 Right:
 skeletonization (on a smoothed version of the polygon).
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Minisec
polygonSkeleton
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonSkeleton
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
skeleton
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the skeleton of a polygon with a dense distribution of vertices,
 using algorithm from 
\begin_inset CommandInset citation
LatexCommand citet
key "Ogniewicz_1995_PatRec"
literal "false"

\end_inset

.
 See Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Triangulation-Skeleton"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
 The result is given as a pair of arguments,
 containing the coordinates of the skeletong vertices,
 and the edges as pairs of indices to adjacent skeleton vertices.
 See the chapter on graphs for manipulation of such data (chapter
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "chap:Graphs"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Minisec
medialAxisConvex
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
medialAxisConvex
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the medial axis of a convex polygon (not fully functional).
\end_layout

\begin_layout Minisec
polygonSymmetryAxis
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonSymmetryAxis
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Tries to identify symmetry axis of a polygon.
\end_layout

\begin_layout Section
Utility functions
\end_layout

\begin_layout Standard
Some conversion functions,
 and I/O utilities.
\end_layout

\begin_layout Minisec
polygonToPolyshape
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonToPolyshape
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Converts a MatGeom polygon to a MATLAB polyshape
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polyshape
\end_layout

\end_inset

 object.
\end_layout

\begin_layout Minisec
polygonToRow
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonToRow
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Converts polygon coordinates to a row vector.
\end_layout

\begin_layout Minisec
rowToPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
rowToPolygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a polygon from a row vector.
\end_layout

\begin_layout Minisec
contourMatrixToPolylines
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
contourMatrixToPolylines
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Converts a contour matrix array into a polyline set.
 Can be used to convert the result of the 
\begin_inset Quotes eld
\end_inset

contours
\begin_inset Quotes erd
\end_inset

 function.
\end_layout

\begin_layout Minisec
readPolygonSet
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
readPolygonSet
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Reads a set of simple polygons stored in a file.
\end_layout

\begin_layout Minisec
writePolygonSet
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
writePolygonSet
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Writes a set of simple polygons into a file.
\end_layout

\begin_layout Chapter
Module graphs
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "chap:Graphs"

\end_inset


\end_layout

\begin_layout Standard
The aim of this module is to provide functions to easily create,
 modify and display geometric graphs (geometric in a sense the nodes are associated to geometric position in 2D or 3D).
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
minitoc
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Definitions
\end_layout

\begin_layout Standard
\begin_inset Note Note
status open

\begin_layout Plain Layout
quick tour
\end_layout

\end_inset


\end_layout

\begin_layout Standard
The Graph module provides functionnalities for the processing of geometric graphs.
 
\series bold
Graphs
\series default
 are defined by a set of 
\series bold
nodes
\series default
 (or 
\series bold
vertices
\series default
),
 and a relation operator that defines which nodes are neighbors.
 
\series bold
Geometric graphs
\series default
 additionally associate each node to a position,
 as a 2D or 3D point (Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Sample-Graph"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/graphs/graph_def/graph_def.png
	lyxscale 50
	width 40text%
	rotateOrigin centerTop

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Sample-Graph"

\end_inset

Graphical representation of a sample graph composed of six vertices (red dots) and seven edges (blue lines).
 
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Section
Data representation
\end_layout

\begin_layout Standard
Geometric graphs gather geometric information (through the position of vertices) and topological information (through the vertex adjacency information).
 Vertex positions are stored as a numeric array (like a point set).
 The topology of the graph can be represented in different way:
\end_layout

\begin_layout Description
adjacency
\begin_inset space ~
\end_inset

list associates to each vertex,
 the list of adjacent vertices
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
\begin_inset Flex URL
status open

\begin_layout Plain Layout

https://en.wikipedia.org/wiki/Adjacency_list
\end_layout

\end_inset


\end_layout

\end_inset

 (Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Graph-Representations"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-a).
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset Graphics
	filename images/graphs/graph_def/graph_adjacency_list.png
	lyxscale 50
	special height=4cm

\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Adjacency list.
\end_layout

\end_inset


\end_layout

\end_inset

 
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/graphs/graph_def/graph_adjacency_matrix.png
	lyxscale 50
	special height=3cm

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Adjacency Matrix.
\end_layout

\end_inset


\end_layout

\end_inset


\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset Graphics
	filename images/graphs/graph_def/graph_edge_adjacencies.png
	lyxscale 50
	special height=3.5cm

\end_inset

 
\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\begin_inset space ~
\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Edge Adjacency.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Graph-Representations"

\end_inset

Several representations of the topological information within the sample graph in Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Sample-Graph"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
 (a) Vertex adjacency list.
 (b) Vertex adjacency matrix.
 (c) Edge vertex adjacency.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Description
adjacency
\begin_inset space ~
\end_inset

matrix is a square 
\begin_inset Formula $n_{v}\times n_{v}$
\end_inset

 matrix (where 
\begin_inset Formula $n_{v}$
\end_inset

 is the number of vertices) such that the coefficient 
\begin_inset Formula $m_{ij}=1$
\end_inset

 if the vertex 
\begin_inset Formula $i$
\end_inset

 is adjacent to the vertex 
\begin_inset Formula $j$
\end_inset

,
 and 0 otherwise (Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Graph-Representations"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-b).
 Vertices may be considered adjacent to themselves,
 in that case the diagonal elements of the matrix are set to 1.
\end_layout

\begin_layout Description
edge
\begin_inset space ~
\end_inset

adjacency (or more simply 
\series bold
edge list
\series default
) is a 
\begin_inset Formula $n_{e}\times2$
\end_inset

 array containing for each edge,
 the indices of the two adjacent edges (Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Graph-Representations"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-c).
 In the case of undirected edges,
 it may be convenient to consider 
\begin_inset Formula $v_{1}$
\end_inset

 as the vertex with the lower index (the convention is used withn MatGeom).
\end_layout

\begin_layout Standard
Within MatGeom,
 most functions represent graphs using two variables 
\begin_inset Quotes eld
\end_inset


\series bold
nodes
\series default

\begin_inset Quotes erd
\end_inset

 and 
\begin_inset Quotes eld
\end_inset


\series bold
edges
\series default

\begin_inset Quotes erd
\end_inset

,
 where nodes contains the position of vertices,
 and edges corresponds to the edge adjacency array.
 These two information can be manipulated individually,
 or be fields of a structure.
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

nodes = [10 10;20 10;10 20;20 20;28 15;33 22];
\end_layout

\begin_layout Plain Layout

edges = [1 2;1 3;2 4;2 5;3 4;4 5;5 6];
\end_layout

\begin_layout Plain Layout

drawGraph(nodes,
 edges);
 axis([0 40 0 30]);
\end_layout

\begin_layout Plain Layout

% equivalent structure
\end_layout

\begin_layout Plain Layout

graph = struct('nodes',
 nodes,
 'edges',
 edges);
\end_layout

\begin_layout Plain Layout

figure;
 drawGraph(graph);
 axis([0 40 0 30]);
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Some graph functions consider adjacency list,
 as a cell array where each cell contains the indices of the neighbor vertices.
\end_layout

\begin_layout Standard
Others arrays may sometimes be used:
\end_layout

\begin_layout Description
faces which contains indices of vertices of each face (either a double array,
 or a cell array)
\end_layout

\begin_layout Description
cells which contains indices of faces of each cell.
\end_layout

\begin_layout Standard
Finally,
 
\series bold
values
\series default
 may be associated to either graph vertices of edges.
 For example,
 a weight may be associated to edges to compute shortest paths.
 In that case,
 the value array is usually given as additional argument to the computation function.
\end_layout

\begin_layout Standard
\begin_inset Newpage clearpage
\end_inset


\end_layout

\begin_layout Section
Creation of graphs
\end_layout

\begin_layout Standard
Except for demonstration purpose,
 graphs are rarely created manually.
 Several functions in MatGeom are provided for creating graphs from a set of points.
\end_layout

\begin_layout Subsection
Create graphs from point sets
\end_layout

\begin_layout Standard
The library contains several functions to generate classical graphs from a set of points.
 Some of them are illustrated on Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Sample-Graphs"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Minisec
delaunayGraph
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
delaunayGraph
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Graph associated to Delaunay triangulation
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
\begin_inset Flex URL
status open

\begin_layout Plain Layout

https://en.wikipedia.org/wiki/Delaunay_triangulation
\end_layout

\end_inset


\end_layout

\end_inset

 of input points (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Sample-Graphs"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-a).
\end_layout

\begin_layout Minisec
euclideanMST
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
euclideanMST
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Build the euclidean minimal spanning tree (MST) of a set of points.
 The minimal spanning tree is the graph with the smallest total length of edges that connect all the nodes of the graph (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Sample-Graphs"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-c).
\end_layout

\begin_layout Minisec
prim_mst
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
mst
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the minimal spanning tree by using Prim's algorithm.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/graphs/sedgewickPoints_delaunayGraph.png
	width 22theight%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Delaunay Graph
\end_layout

\end_inset


\end_layout

\end_inset


\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status collapsed

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/graphs/sedgewickPoints_gabrielGraph.png
	width 22theight%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Gabriel Graph
\end_layout

\end_inset


\end_layout

\end_inset


\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status collapsed

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/graphs/sedgewickPoints_MinimalSpanningTree.png
	width 22theight%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Delaunay Graph
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Sample-Graphs"

\end_inset

Several graphs generated from a simple set of points.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Minisec
knnGraph
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
knnGraph
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Create the k-nearest neighbors graph of a set of points.
\end_layout

\begin_layout Minisec
relativeNeighborhoodGraph
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
relativeNeighborhoodGraph
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the Relative Neighborhood Graph (RNG) of a set of points.
 The RNG
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
\begin_inset Flex URL
status open

\begin_layout Plain Layout

https://en.wikipedia.org/wiki/Relative_neighborhood_graph
\end_layout

\end_inset


\end_layout

\end_inset

 connects two points by an edge whenever there does not exist any third point that is closer to candidate points than they are to each other.
\end_layout

\begin_layout Minisec
gabrielGraph
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
gabrielGraph
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the Gabriel Graph of a set of points.
 Gabriel Graph
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
\begin_inset Flex URL
status open

\begin_layout Plain Layout

https://en.wikipedia.org/wiki/Gabriel_graph
\end_layout

\end_inset


\end_layout

\end_inset

 connects points if the disc formed by the diameter of the two points does not contain any other point from the set (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Sample-Graphs"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-b).
\end_layout

\begin_layout Subsection
Voronoi Graphs
\end_layout

\begin_layout Standard
Voronoi diagrams are a fundamental data structure in geometry 
\begin_inset CommandInset citation
LatexCommand citep
key "Aurenhammer_1991_ACM"
literal "false"

\end_inset

.
 Several functions are provided to generate graphs corresponding to Voronoi diagram of a set of points.
 In particular,
 Centroidal Voronoi Diagrams (CVD),
 or Centroidal Voronoi Tesselations (CVT),
 correspond to the case where the germs of the diagram are located on the centroids of the Voronoi polygons 
\begin_inset CommandInset citation
LatexCommand citep
key "Du1999"
literal "false"

\end_inset

.
\end_layout

\begin_layout Minisec
voronoi2d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
voronoi2d
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes a voronoi diagram as a graph structure.
\end_layout

\begin_layout Minisec
boundedVoronoi2d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
boundedVoronoi2d
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the voronoi diagram constrained to a box of a set of germs,
 and return the result as a graph structure (see Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Voronoi-Diagram"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\begin_inset Note Note
status collapsed

\begin_layout Minisec
centroidalVoronoi2d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
centroidalVoronoi2d
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout
Computes a centroidal Voronoi tesselation within a polygon.
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
boundedCentroidalVoronoi2d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
boundedCentroidalVoronoi2d
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes a centroidal Voronoi diagram (or tesselation) 
\series bold
constrained to a box
\series default
 of a set of germs,
 and return the result as a graph.
 
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/graphs/voronoi/boundedVoronoi2d_demo_crop.png
	lyxscale 50
	width 35text%

\end_inset


\begin_inset Graphics
	filename images/graphs/voronoi/boundedCVD2d_demo_crop.png
	lyxscale 50
	width 35text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Voronoi-Diagram"

\end_inset

Voronoi diagram,
 and Centroidal Voronoi Diagram obtained after 50 iterations..
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\end_layout

\begin_layout Minisec
centroidalVoronoi2d_MC
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
centroidalVoronoi2d_MC
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes a centroidal Voronoi diagram (or tesselation) 
\series bold
constrained to a polygon
\series default
,
 by using a Monte-Carlo algorithm.
\end_layout

\begin_layout Minisec
cvtUpdate
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
cvtUpdate
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Updates the germs of a CVT with given points (used by function centroidalVoronoi2d_MC).
\end_layout

\begin_layout Minisec
cvtIterate
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
cvtIterate
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Updates the germs of a CVT using random points with given density (used by function centroidalVoronoi2d_MC).
\end_layout

\begin_layout Subsection
Creation of graphs from images
\end_layout

\begin_layout Standard
Some functions allows to generate graphs from a (usually binary) 2D or 3D image.
 In most cases,
 node positions correspond to pixels or voxels of the original image.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status collapsed

\begin_layout Plain Layout
\align center
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/graphs/images/sample_image_crop.png
	width 25text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Image.
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/graphs/images/imageGraph_2d_crop.png
	width 25text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Adjacency graph.
\end_layout

\end_inset


\end_layout

\end_inset


\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/graphs/images/imageBoundaryGraph_2d_crop.png
	width 25text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Boundary graph.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Image-Graphs-2d"

\end_inset

Creation of graphs from a binary image.
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\end_layout

\begin_layout Minisec
imageGraph
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
imageGraph
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Create equivalent graph of a binary image (Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Image-Graphs-2d"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-b).
\end_layout

\begin_layout Minisec
imageBoundaryGraph
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
imageBoundaryGraph
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Get boundary of image as a graph (Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Image-Graphs-2d"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-c).
\end_layout

\begin_layout Standard
\begin_inset Note Note
status open

\begin_layout Minisec
gcontour2d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
gcontour2d
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout
Creates contour graph of a 2D binary image.
\end_layout

\begin_layout Minisec
gcontour3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
gcontour3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Plain Layout
Create contour graph of a 3D binary image.
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Operators on graphs
\end_layout

\begin_layout Subsection
Geodesic and shortest path operations
\end_layout

\begin_layout Minisec
grShortestPath
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grShortestPath
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Find a shortest path between two nodes in the graph.
\end_layout

\begin_layout Minisec
grPropagateDistance
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grPropagateDistance
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distance!geodesic
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
geodesic!distance
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Propagates distances from a vertex to other vertices.
\end_layout

\begin_layout Minisec
grVertexEccentricity
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grVertexEccentricity
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Eccentricity of vertices in the graph.
\end_layout

\begin_layout Minisec
graphDiameter
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
graphDiameter
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
diameter!graph
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Diameter of a graph.
\end_layout

\begin_layout Minisec
graphPeripheralVertices
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
graphPeripheralVertices
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Peripheral vertices of a graph.
\end_layout

\begin_layout Minisec
graphCenter
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
graphCenter
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Center of a graph.
\end_layout

\begin_layout Minisec
graphRadius
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
graphRadius
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Radius of a graph.
\end_layout

\begin_layout Minisec
grFindGeodesicPath
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grFindGeodesicPath
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
geodesic
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Find a geodesic path between two nodes in the graph.
\end_layout

\begin_layout Minisec
grFindMaximalLengthPath
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grFindMaximalLengthPath
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Find a path that maximizes sum of edge weights.
\end_layout

\begin_layout Subsection
Filtering operations on valued Graph
\end_layout

\begin_layout Standard
These functions adapt classical filtering operators to operate on graphs data stucture.
 An array of values associated to the vertices must be provided to the functions.
 The new values are returned as result.
\end_layout

\begin_layout Minisec
grMean
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grMean
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Compute mean from neighbours.
\end_layout

\begin_layout Minisec
grMedian
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grMedian
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Compute median from neighbours.
\end_layout

\begin_layout Minisec
grDilate
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grDilate
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Morphological dilation on graph.
\end_layout

\begin_layout Minisec
grErode
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grErode
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Morphological erosion on graph.
\end_layout

\begin_layout Minisec
grClose
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grClose
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Morphological closing on graph.
\end_layout

\begin_layout Minisec
grOpen
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grOpen
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Morphological opening on graph.
\end_layout

\begin_layout Subsection
Operations for geometric graphs
\end_layout

\begin_layout Minisec
grEdgeLengths
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grEdgeLengths
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Compute length of edges in a geometric graph.
\end_layout

\begin_layout Minisec
grMergeNodeClusters
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grMergeNodeClusters
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Merge cluster of connected nodes in a graph.
\end_layout

\begin_layout Minisec
grMergeNodesMedian
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grMergeNodesMedian
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Replace several nodes by their median coordinate.
\end_layout

\begin_layout Minisec
clipGraph
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipGraph
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Clip a graph with a rectangular area.
\end_layout

\begin_layout Minisec
clipGraphPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipGraphPolygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Clip a graph with a polygon.
\end_layout

\begin_layout Minisec
clipMesh2dPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipMesh2dPolygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Clip a planar mesh with a polygon.
\end_layout

\begin_layout Minisec
addSquareFace
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
addSquareFace
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Add a (square) face defined from its vertices to a graph.
\end_layout

\begin_layout Minisec
grFaceToPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grFaceToPolygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Compute the polygon corresponding to a graph face.
\end_layout

\begin_layout Minisec
graph2Contours
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
graph2Contours
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Convert a graph to a set of contour curves.
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Graph editing 
\end_layout

\begin_layout Subsection
Graph information
\end_layout

\begin_layout Standard
Several functions to obtain quantitative information about a graph.
\end_layout

\begin_layout Minisec
grNodeDegree
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grNodeDegree
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Degree of a node in a (undirected) graph.
\end_layout

\begin_layout Minisec
grNodeInnerDegree
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grNodeInnerDegree
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Inner degree of a node in a graph.
\end_layout

\begin_layout Minisec
grNodeOuterDegree
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grNodeOuterDegree
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Outer degree of a node in a graph.
\end_layout

\begin_layout Minisec
grAdjacentNodes
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grAdjacentNodes
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Find list of nodes adjacent to a given node.
\end_layout

\begin_layout Minisec
grAdjacentEdges
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grAdjacentEdges
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Find list of edges adjacent to a given node.
\end_layout

\begin_layout Minisec
grOppositeNode
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grOppositeNode
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Return opposite node in an edge.
\end_layout

\begin_layout Minisec
grLabel
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grLabel
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Associate a label to each connected component of the graph.
\end_layout

\begin_layout Subsection
Conversions and simplification
\end_layout

\begin_layout Minisec
adjacencyListToEdges
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
adjacencyListToEdges
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Convert an adjacency list to an edge array.
\end_layout

\begin_layout Minisec
pruneGraph
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
pruneGraph
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Remove all edges with a terminal vertex.
\end_layout

\begin_layout Minisec
mergeGraphs
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
mergeGraphs
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Merge two graphs,
 by adding nodes,
 edges and faces lists.
\end_layout

\begin_layout Minisec
grMergeNodes
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grMergeNodes
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Merge two (or more) nodes in a graph.
\end_layout

\begin_layout Minisec
grMergeMultipleNodes
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grMergeMultipleNodes
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Simplify a graph by merging multiple nodes.
\end_layout

\begin_layout Minisec
grMergeMultipleEdges
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grMergeMultipleEdges
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Remove all edges sharing the same extremities.
\end_layout

\begin_layout Minisec
grSimplifyBranches
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grSimplifyBranches
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Replace branches of a graph by single edges.
\end_layout

\begin_layout Subsection
Low level graph edition
\end_layout

\begin_layout Standard
Some functions for removing elements from a graph by maintaining the consistency of the informations.
\end_layout

\begin_layout Minisec
grRemoveNode
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grRemoveNode
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Remove a node in a graph.
\end_layout

\begin_layout Minisec
grRemoveNodes
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grRemoveNodes
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Remove several nodes in a graph.
\end_layout

\begin_layout Minisec
grRemoveEdge
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grRemoveEdge
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Remove an edge in a graph.
\end_layout

\begin_layout Minisec
grRemoveEdges
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
grRemoveEdges
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Remove several edges from a graph.
\end_layout

\begin_layout Section
Display
\end_layout

\begin_layout Standard
Display a graph,
 or specific elements of a graph.
\end_layout

\begin_layout Minisec
drawGraph
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawGraph
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draw a graph,
 given as a set of vertices and edges.
\end_layout

\begin_layout Minisec
drawGraphEdges
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawGraphEdges
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draw edges of a graph.
\end_layout

\begin_layout Minisec
fillGraphFaces
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fillGraphFaces
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Fill faces of a graph with specified color.
\end_layout

\begin_layout Minisec
drawDigraph
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawDigraph
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draw a directed graph,
 given as a set of vertices and edges.
\end_layout

\begin_layout Minisec
drawDirectedEdges
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawDirectedEdges
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draw edges with arrow indicating direction.
\end_layout

\begin_layout Minisec
drawEdgeLabels
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawEdgeLabels
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draw values associated to graph edges.
\end_layout

\begin_layout Minisec
drawNodeLabels
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawNodeLabels
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draw values associated to graph nodes.
\end_layout

\begin_layout Minisec
drawSquareMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawSquareMesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draw a 3D square mesh given as a graph.
\end_layout

\begin_layout Minisec
patchGraph
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
patchGraph
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Transform 3D graph (mesh) into a patch handle.
\end_layout

\begin_layout Section
Reading and writing graphs
\end_layout

\begin_layout Standard
Read and write graphs from text files using simple format.
 
\end_layout

\begin_layout Subsection
Format
\end_layout

\begin_layout Standard
An example of graph is given in the following listing.
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

# graph
\end_layout

\begin_layout Plain Layout

# nodes
\end_layout

\begin_layout Plain Layout

5 2
\end_layout

\begin_layout Plain Layout

10 10
\end_layout

\begin_layout Plain Layout

20 10
\end_layout

\begin_layout Plain Layout

10 20
\end_layout

\begin_layout Plain Layout

20 20
\end_layout

\begin_layout Plain Layout

27 15
\end_layout

\begin_layout Plain Layout

# edges
\end_layout

\begin_layout Plain Layout

6
\end_layout

\begin_layout Plain Layout

1 2
\end_layout

\begin_layout Plain Layout

1 3
\end_layout

\begin_layout Plain Layout

2 4
\end_layout

\begin_layout Plain Layout

2 5
\end_layout

\begin_layout Plain Layout

3 4
\end_layout

\begin_layout Plain Layout

4 5
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Lines starting with a dash are comments.
 The first part of the file describes the nodes.
 It starts with a line containing the number of nodes,
 and the dimensionality of the graph (usually 2 or 3).
 Then the coordinates of the nodes follow.
\end_layout

\begin_layout Standard
The second part of the file describes the edges.
 It start with a line containing the number of edges.
 Then the index of source and target vertices of each edge follow.
 Vertex indices are 1-indexed.
\end_layout

\begin_layout Subsection
Functions
\end_layout

\begin_layout Minisec
readGraph
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
readGraph
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Read a graph from a text file.
\end_layout

\begin_layout Minisec
writeGraph
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
writeGraph
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Write a graph to an ascii file.
\end_layout

\begin_layout Chapter
Module geom3d
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "chap:geom3d"

\end_inset


\end_layout

\begin_layout Standard
The geom3d module allows to create,
 manipulate,
 transform,
 and visualize geometrical 3D primitives,
 such as points,
 lines,
 planes,
 polyhedra,
 circles and spheres.
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
minitoc
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\begin_inset Note Note
status open

\begin_layout Section
Conventions
\end_layout

\begin_layout Subsection
Geometric primitives
\end_layout

\begin_layout Plain Layout
\begin_inset Note Note
status open

\begin_layout Plain Layout
Necessary section ?
\end_layout

\end_inset


\end_layout

\begin_layout Description
Point [x0 y0 z0]
\end_layout

\begin_layout Description
Vector [dx dy dz]
\end_layout

\begin_layout Description
Line [x0 y0 z0 dx dy dz]
\end_layout

\begin_layout Description
Edge [x1 y1 z1 x2 y2 z2]
\end_layout

\begin_layout Description
Plane [x0 y0 z0 dx1 dy1 dz1 dx2 dy2 dz2]
\end_layout

\begin_layout Description
Sphere [x0 y0 z0 R]
\end_layout

\begin_layout Description
Circle [x0 y0 z0 R PHI THETA PSI] (origin+center+normal+'roll').
\end_layout

\begin_layout Description
Ellipsoid [x0 y0 z0 A B C PHI THETA PSI]
\end_layout

\begin_layout Description
Cylinder [X1 Y1 Z1 X2 Y2 Z2 R]
\end_layout

\begin_layout Description
Box [xmin xmax ymin ymax zmin zmax].
 Used for clipping shapes.
\end_layout

\begin_layout Description
Polygons represented by N-by-3 array of points,
 the last point is not necessarily the same as the first one.
 Points must be coplanar.
\end_layout

\begin_layout Plain Layout
\begin_inset Note Note
status open

\begin_layout Plain Layout
Add Euler angles convention?
 Some docs already in section 3D Angles
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Section
Introduction
\end_layout

\begin_layout Standard
The geom3d module is the equivalent of the geom2d module for the 3D Euclidean space.
 It provides functions for processing 3D points,
 vectors,
 linear shapes (including 3D lines and planes),
 as well as smooth surfaces such as ellipsoids.
 
\end_layout

\begin_layout Standard
As for the geom2d module,
 geometries are represented using row vectors (see table 
\begin_inset CommandInset ref
LatexCommand ref
reference "tab:Geometries3D"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
 Points and vectors are represented as 
\begin_inset Formula $1\times3$
\end_inset

 row vectors.
 Lines and planes concatenate the coordinates of the origin and the components of the direction vector(s).
 
\end_layout

\begin_layout Standard
\begin_inset Float table
placement h
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="9" columns="4">
<features tabularvalignment="middle">
<column alignment="left" valignment="top">
<column alignment="center" valignment="top">
<column alignment="left" valignment="top">
<column alignment="left" valignment="top">
<row>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Geometry
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Size
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Params.
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Comments
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" topline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
point,
 vector
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $1\times3$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $[x,y]$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Coordinates
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
line
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $1\times6$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $[x_{0},y_{0},z_{0,}d_{x},d_{y},d_{z}]$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Origin and direction
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
segment
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $1\times6$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $[x_{1},y_{1},z_{1},x_{2},y_{2},z_{2}]$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Extremity points
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
plane
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $1\times9$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="1">
<features tabularvalignment="middle">
<column alignment="none" valignment="top" special="@{}c@{}">
<row>
<cell alignment="none" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $[x_{0},y_{0},z_{0},v_{1,x},v_{1,y},v_{1,z},$
\end_inset


\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="none" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $v_{2,x},v_{2,y},v_{2,z}]$
\end_inset


\end_layout

\end_inset
</cell>
</row>
</lyxtabular>

\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Origin and two directions
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
ball
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $1\times3$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $[x_{c},y_{c},z_{c},r]$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Center and radius
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
ellipsoid
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $1\times9$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="1">
<features tabularvalignment="middle">
<column alignment="none" valignment="top" special="@{}c@{}">
<row>
<cell alignment="none" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $[x_{c},y_{c},z_{c},r_{a},r_{b},r_{c},$
\end_inset


\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="none" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $\varphi,\theta,\psi]$
\end_inset


\end_layout

\end_inset
</cell>
</row>
</lyxtabular>

\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Center,
 sizes,
 orientation
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
cylinder
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $1\times7$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $[x_{1},y_{1},z_{1},x_{2},y_{2},z_{2},r]$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Extremity points and radius
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
box
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $1\times6$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="1">
<features tabularvalignment="middle">
<column alignment="none" valignment="top" special="@{}c@{}">
<row>
<cell alignment="none" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $[x_{min},x_{max},y_{min},y_{max},$
\end_inset


\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="none" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $z_{min},z_{max}]$
\end_inset


\end_layout

\end_inset
</cell>
</row>
</lyxtabular>

\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="1">
<features tabularvalignment="middle">
<column alignment="none" valignment="top" special="@{}c@{}">
<row>
<cell alignment="none" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Used for bounding boxes
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="none" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
and clipping
\end_layout

\end_inset
</cell>
</row>
</lyxtabular>

\end_inset


\end_layout

\end_inset
</cell>
</row>
</lyxtabular>

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "tab:Geometries3D"

\end_inset

Summary of 3D geometry representations.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Subsection
Orientation of shapes
\end_layout

\begin_layout Standard
The orientation of 3D shapes (ellipsoids,
 cuboids,
 3D circles...) can be represented by a combination of rotation angles around reference axes.
 Two different conventions are used to represent the orientation,
 depending on the type of the shape:
 
\end_layout

\begin_layout Itemize
elongated or "solid" shapes (ellipsoids,
 cuboids,
 cylinders...) consider two angles for representing the direction of the main axis of the shape,
 and one angle to represent the rotation of the shape around that axis.
 The direction is given by a (azimut,
 elevation) pair (see Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Orientation-3D-Shapes"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
 This results in a "yaw-pitch-roll" triplet of angles (
\begin_inset Formula $\varphi$
\end_inset

,
 
\begin_inset Formula $\theta$
\end_inset

,
 
\begin_inset Formula $\psi$
\end_inset

),
 corresponding to XYZ Euler angles (see also section
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "subsec:Euler-Angles"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Itemize
flat objects (3D ellipses or discs),
 or shapes organized around a symmetry axis consider two spherical angles for representing the main direction (usually that of the normal angle of the supporting plane),
 and one angle for representing the rotation around the normal axis.
 Spherical angle uses a (colatitude,azimut) pair (see Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Orientation-3D-Shapes"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
 This results in a triplet (
\begin_inset Formula $\theta$
\end_inset

,
 
\begin_inset Formula $\varphi$
\end_inset

,
 
\begin_inset Formula $\psi$
\end_inset

) of three angles:
 
\begin_inset Formula $\theta$
\end_inset

 is the colatitude,
 
\begin_inset Formula $\varphi$
\end_inset

 is the azimut,
 and 
\begin_inset Formula $\psi$
\end_inset

 is the rotation angle around axis.
 This corresponds to Euler angles with the "ZYZ" convention.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/geom3d/cylinder_angles.png
	width 45text%

\end_inset


\begin_inset Graphics
	filename images/geom3d/ellipse3d_angles.png
	width 45text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Orientation-3D-Shapes"

\end_inset

Orientation of 3D shapes.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Standard
Orientation angles of 3D shapes are always given in degrees.
\end_layout

\begin_layout Section
Angles and coordinate systems
\end_layout

\begin_layout Standard
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angle!3D
\end_layout

\end_inset

A precise definition of the coordinate systems is necessary to further define 3D transforms (in section
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "sec:3D-Transforms"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
 Several of these coordinate systems are based on angles.
 For example the spherical coordinates can be useful for considering positions of dimensionless objects such as points.
 
\end_layout

\begin_layout Standard
Contrary to the planar case,
 several angles are often necessary to define a coordinate system or a 3D transform.
 Euler angles are a popular solution to represent arbitrary 3D rotations,
 but several definitions exist.
 They are presented in section
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "subsec:Euler-Angles"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Subsection
Spherical coordinates
\end_layout

\begin_layout Standard
Spherical coordinates comprise three components:
 two angular coordinates on the surface of the sphere,
 and the distance to origin.
 They can be useful for considering positions of dimensionless objects such as points.
 
\end_layout

\begin_layout Standard
The two spherical angles used by MatGeom are 1) the colatitude,
 corresponding to the angle with the 
\begin_inset Formula $z$
\end_inset

-axis,
 and 2) the azimut (See Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Coordinates-systems"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
 The last coordinate is the distance to the origin.
 Note that a different convention from standard Matlab was used:
 a discussion can be found here
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
\begin_inset Flex URL
status open

\begin_layout Plain Layout

http://www.physics.oregonstate.edu/bridge/papers/spherical.pdf
\end_layout

\end_inset


\end_layout

\end_inset

.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/geom3d/spherical-angles.png
	width 45text%

\end_inset


\begin_inset Graphics
	filename images/geom3d/cylindrical_coordinates.png
	width 45text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Coordinates-systems"

\end_inset

Definition of spherical and cylindrincal coordinates.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Minisec
sph2cart2
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
sph2cart2
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts spherical coordinates to cartesian coordinates.
\end_layout

\begin_layout Minisec
cart2sph2
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
cart2sph2
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts cartesian coordinates to spherical coordinates.
\end_layout

\begin_layout Minisec
cart2sph2d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
cart2sph2d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts cartesian coordinates to spherical coordinates in degrees.
\end_layout

\begin_layout Minisec
sph2cart2d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
sph2cart2d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts spherical coordinates to cartesian coordinates in degrees.
\end_layout

\begin_layout Subsection
Cylindrical coordinates
\end_layout

\begin_layout Standard
Cylindrical coordinates comprise three components:
 the azimut angle,
 the distance to the 
\begin_inset Formula $z$
\end_inset

-axis,
 and the altitude (See Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Coordinates-systems"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Minisec
cart2cyl
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
cart2cyl
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts cartesian to cylindrical coordinates.
\end_layout

\begin_layout Minisec
cyl2cart
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
cyl2cart
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts cylindrical to cartesian coordinates.
\end_layout

\begin_layout Subsection
Other functions for angles
\end_layout

\begin_layout Minisec
anglePoints3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
anglePoints3d
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angle!three points (3D)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes angle between three 3D points.
\end_layout

\begin_layout Minisec
sphericalAngle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
sphericalAngle
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angle!spherical
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes angle between points on the sphere.
\end_layout

\begin_layout Minisec
angleSort3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angleSort3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Sorts 3D coplanar points according to their angles in plane.
\end_layout

\begin_layout Minisec
randomAngle3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
randomAngle3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns a 3D angle uniformly distributed on unit sphere.
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Points and Vectors
\end_layout

\begin_layout Standard
Both points and vectors are represented by a 1-by-3 array of coordinates:
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

point = [x0 y0 z0];
\end_layout

\begin_layout Plain Layout

vector = [dx dy dz];
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Arrays of points or vectors are represented by N-by-3 arrays of coordinates.
\end_layout

\begin_layout Subsection
Points
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "subsec:Points-3D"

\end_inset


\end_layout

\begin_layout Standard
The library provides several generic functions for working with points or point sets.
\end_layout

\begin_layout Minisec
midPoint3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
midPoint3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Middle point of two 3D points or of a 3D edge.
\end_layout

\begin_layout Minisec
isCoplanar
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isCoplanar
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Tests for coplanarity of points in 3-space.
\end_layout

\begin_layout Minisec
transformPoint3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
transformPoint3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Applies a 3D affine transform to a point or an array of points.
 See the section 
\begin_inset CommandInset ref
LatexCommand ref
reference "sec:3D-Transforms"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

 for the creation of 3D transform matrices.
\end_layout

\begin_layout Minisec
distancePoints3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distancePoints3d
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status open

\begin_layout Plain Layout
distance!points (3D)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the Euclidean distance between pairs of 3D Points.
\end_layout

\begin_layout Minisec
clipPoints3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipPoints3d
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipping!points (3D)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Clips a set of points by a 3D box or by another 3d shape.
\end_layout

\begin_layout Minisec
drawPoint3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawPoint3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws 3D point on the current axis.
\end_layout

\begin_layout Subsection
3D Vectors
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "subsec:Vectors-3D"

\end_inset


\end_layout

\begin_layout Standard
Several functions are also provided to compute derived quantities from 3D vectors (products,
 angles...).
\end_layout

\begin_layout Minisec
normalizeVector3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
normalizeVector3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Normalizes a 3D vector to have norm equal to 1.
\end_layout

\begin_layout Minisec
vectorNorm3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
vectorNorm3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Norm of a 3D vector or of set of 3D vectors.
\end_layout

\begin_layout Minisec
hypot3
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
hypot3
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the length of a 3D vector,
 equivalent to the diagonal length of a cuboidal 3D box.
\end_layout

\begin_layout Minisec
crossProduct3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
crossProduct3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Vector cross product,
 faster than inbuilt MATLAB cross.
\end_layout

\begin_layout Minisec
vectorAngle3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
vectorAngle3d
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angle!vectors (3D)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Angle between two 3D vectors.
\end_layout

\begin_layout Minisec
isParallel3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isParallel3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Checks parallelism of two 3D vectors.
\end_layout

\begin_layout Minisec
isPerpendicular3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isPerpendicular3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Checks orthogonality of two 3D vectors.
\end_layout

\begin_layout Minisec
transformVector3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
transformVector3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Applies a 3D affine transform to a vector or an array of vectors.
 See the section 
\begin_inset CommandInset ref
LatexCommand ref
reference "sec:3D-Transforms"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

 for the definition of transforms.
\end_layout

\begin_layout Minisec
drawVector3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawVector3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws vector at a given position.
\end_layout

\begin_layout Subsection
Boxes
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "subsec:Boxes-3D"

\end_inset


\end_layout

\begin_layout Standard
3D boxes are used to represent the physical extents of 3D geometries (bounding boxes),
 or to clip geometries.
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

box = [xmin xmax  ymin ymax  zmin zmax];
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/geom3d/boxes3d_intersect_merge.png
	lyxscale 75
	width 70text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Operations-on-3D-Boxes"

\end_inset

Operations on 3D boxes:
 intersection and merge.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Minisec
drawBox3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawBox3d
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draws a 3D box,
 defined by bounding coordinates along each dimension.
\end_layout

\begin_layout Minisec
box3dVolume
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
box3dVolume
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the the volume of a 3-dimensional box.
\end_layout

\begin_layout Minisec
boundingBox3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
boundingBox3d
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the bounding box of a set of 3D points.
\end_layout

\begin_layout Minisec
intersectBoxes3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectBoxes3d
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the intersection box of two 3D boxes,
 i.e.
 the largest box that is contained in both input boxes (See Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Operations-on-3D-Boxes"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Minisec
mergeBoxes3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
mergeBoxes3d
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the union of two 3D boxes,
 i.e.
 the smallest box that contains both input boxes (See Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Operations-on-3D-Boxes"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Minisec
orientedBox3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
orientedBox3d
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the 3D object-oriented bounding box of a set of points.
 The bounding box is computed by first identifying the face of the convex hull that generates the smallest depth,
 then computing the 2D bounding box on the plane projection.
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Linear shapes
\end_layout

\begin_layout Standard
Linear shapes comprise straight lines,
 edges (line segments),
 and rays (half-lines).
\end_layout

\begin_layout Standard
A 3D line is represented by a 
\begin_inset Formula $1\times6$
\end_inset

 numeric array resulting from the concatenation of a 3D point (its origin) and a 3D vector (its direction):
 
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

LINE = [X0 Y0 Z0 DX DY DZ];
\end_layout

\end_inset

A 3D ray is represented the same way as a line.
 The difference in the management is performed by the call in different functions (e.g.
 
\begin_inset Quotes eld
\end_inset

clipRay
\begin_inset Quotes erd
\end_inset

 instead of 
\begin_inset Quotes eld
\end_inset

clipLine
\begin_inset Quotes erd
\end_inset

).
\end_layout

\begin_layout Standard
A 3D edge is represented by the coordinates of its extremities:
 
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

EDGE = [X1 Y1 Z1 X2 Y2 Z2];
\end_layout

\end_inset


\end_layout

\begin_layout Subsection
Creation
\end_layout

\begin_layout Minisec
createLine3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createLine3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a 3D (straight) line with various inputs.
\end_layout

\begin_layout Minisec
createRay3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createRay3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a 3D ray (half-line) from two points.
\end_layout

\begin_layout Minisec
fitLine3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fitLine3d
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fitting!line 3D
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Fits a 3D line to a set of points.
\end_layout

\begin_layout Minisec
parallelLine3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
parallelLine3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates 3D line parallel to another one.
\end_layout

\begin_layout Minisec
transformLine3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
transformLine3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Transforms a 3D line with a 3D affine transform.
 See the section 
\begin_inset CommandInset ref
LatexCommand ref
reference "sec:3D-Transforms"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

 for the definition of transforms.
\end_layout

\begin_layout Minisec
reverseLine3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
reverseLine3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns the same 3D line but with opposite orientation.
\end_layout

\begin_layout Subsection
Relations with points
\end_layout

\begin_layout Minisec
distancePointLine3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distancePointLine3d
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distance!point to line (3D)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Euclidean distance between 3D point and line.
\end_layout

\begin_layout Minisec
isPointOnLine3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isPointOnLine3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Tests if a 3D point belongs to a 3D line.
\end_layout

\begin_layout Minisec
projPointOnLine3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
projPointOnLine3d
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
projection!on line (3D)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Projects a 3D point orthogonally onto a 3D line.
\end_layout

\begin_layout Minisec
distancePointEdge3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distancePointEdge3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Minimum distance between a 3D point and a 3D edge.
\end_layout

\begin_layout Minisec
line3dPoint
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
line3dPoint
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a 3D point at a given position on a 3D line.
\end_layout

\begin_layout Minisec
line3dPosition
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
line3dPosition
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns the position of a 3D point projected on a 3D line.
\end_layout

\begin_layout Subsection
Clipping and conversion
\end_layout

\begin_layout Standard
These functions compute the intersection of a linear geometry with a 3D bounding box.
\end_layout

\begin_layout Minisec
clipLine3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipLine3d
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipping!line (3D)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Clips a 3D line with a 3D box and return a 3D edge.
\end_layout

\begin_layout Minisec
clipEdge3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipEdge3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Clips a 3D edge with a cuboid box.
\end_layout

\begin_layout Minisec
clipRay3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipRay3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Clip a 3D ray with a box and return a 3D edge.
\end_layout

\begin_layout Subsection
Utility functions
\end_layout

\begin_layout Minisec
distanceLines3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distanceLines3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Minimal distance between two 3D lines.
\end_layout

\begin_layout Minisec
edgeToLine3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
edgeToLine3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts a 3D edge to a 3D straight line.
\end_layout

\begin_layout Minisec
midPoint3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
midPoint3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the middle point of two 3D points,
 or of a 3D edge,
 depending on size of input argument(s).
\end_layout

\begin_layout Subsection
Drawing
\end_layout

\begin_layout Standard
Drawing functions for linear geometries,
 performing clipping with the bounding box corresponding to the current figure axes.
\end_layout

\begin_layout Minisec
drawLine3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawLine3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a 3D line clipped by the current axes.
\end_layout

\begin_layout Minisec
drawEdge3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawEdge3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws 3D edge in the current axes.
\end_layout

\begin_layout Minisec
drawRay3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawRay3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draw a 3D ray on the current axis.
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Planes 
\end_layout

\begin_layout Standard
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
plane
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Planes are represented by a 3D point (the plane origin) and 2 direction vectors,
 which should not be colinear.
 
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

PLANE = [X0 Y0 Z0 DX1 DY1 DZ1 DX2 DY2 DZ2];
\end_layout

\end_inset


\end_layout

\begin_layout Standard
The plane origin and direction vectors can be accessed by using array indexing:
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

plane = ...
\end_layout

\begin_layout Plain Layout

origin = plane(1,1:3);
\end_layout

\begin_layout Plain Layout

v1 = plane(1,
 4:6);
\end_layout

\begin_layout Plain Layout

v2 = plane(1,
 7:9);
\end_layout

\end_inset


\end_layout

\begin_layout Subsection
Creation and transformations
\end_layout

\begin_layout Minisec
createPlane
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createPlane
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a plane in parametrized form.
\end_layout

\begin_layout Minisec
medianPlane
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
medianPlane
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a plane in the middle of 2 points.
\end_layout

\begin_layout Minisec
fitPlane
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fitPlane
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fitting!plane
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Fits a 3D plane to a set of points.
\end_layout

\begin_layout Minisec
normalizePlane
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
normalizePlane
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Normalizes parametric representation of a plane.
\end_layout

\begin_layout Minisec
parallelPlane
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
parallelPlane
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Parallel to a plane through a point or at a given distance.
\end_layout

\begin_layout Minisec
reversePlane
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
reversePlane
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
orientation!plane
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Returns the same 3D plane but with opposite orientation.
\end_layout

\begin_layout Minisec
transformPlane3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
transformPlane3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Transforms a 3D plane with a 3D affine transform.
 See the section 
\begin_inset CommandInset ref
LatexCommand ref
reference "sec:3D-Transforms"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

 for the definition of transforms.
\end_layout

\begin_layout Subsection
Computing intersections
\end_layout

\begin_layout Minisec
intersectPlanes
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectPlanes
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns the intersection line between 2 planes in space.
\end_layout

\begin_layout Minisec
intersectThreePlanes
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectThreePlanes
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Returns the intersection point between 3 planes in space.
\end_layout

\begin_layout Minisec
intersectLinePlane
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectLinePlane
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Intersection point between a 3D line and a plane.
\end_layout

\begin_layout Minisec
intersectEdgePlane
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectEdgePlane
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns intersection point between a plane and a edge.
\end_layout

\begin_layout Minisec
planesBisector
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
planesBisector
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Bisector plane between two other planes.
\end_layout

\begin_layout Subsection
Point positions
\end_layout

\begin_layout Minisec
planePosition
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
planePosition
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the position of a point on a plane.
\end_layout

\begin_layout Minisec
planePoint
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
planePoint
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the 3D position of a point in a plane.
\end_layout

\begin_layout Minisec
projPointOnPlane
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
projPointOnPlane
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
projection!on plane
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Returns the orthogonal projection of a point on a plane.
\end_layout

\begin_layout Minisec
distancePointPlane
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distancePointPlane
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distance!point to plane
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Signed distance betwen 3D point and plane.
\end_layout

\begin_layout Minisec
isBelowPlane
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isBelowPlane
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Tests whether a point is below or above a plane.
\end_layout

\begin_layout Minisec
projLineOnPlane
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
projLineOnPlane
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns the orthogonal projection of a line on a plane.
\end_layout

\begin_layout Subsection
Measures
\end_layout

\begin_layout Minisec
planeNormal
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
planeNormal
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the normal to a plane.
\end_layout

\begin_layout Minisec
isPlane
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isPlane
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Checks if input is a plane.
\end_layout

\begin_layout Minisec
dihedralAngle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
dihedralAngle
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angle!dihedral
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the dihedral angle between 2 planes.
\end_layout

\begin_layout Subsection
Drawing
\end_layout

\begin_layout Minisec
drawPlane3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawPlane3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a plane clipped by the current axes.
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
3D Polygons
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "sec:Polygons-3D"

\end_inset


\end_layout

\begin_layout Standard
These functions operate on 3D polygons that are not necessarily embedded into a plane.
 As for the 2-dimensional case,
 polygons correspond to closed curves,
 whereas polylines correspond to open curves (see section
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "sec:Curves-3D"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Subsection
Representation
\end_layout

\begin_layout Standard
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygon (3D)
\end_layout

\end_inset

Polygons are represented by 
\begin_inset Formula $N\times3$
\end_inset

 array of vertex coordinates.
 The behaviour is not specified for 3D polygons with non-coplanar vertices.
\end_layout

\begin_layout Standard
Some functions accept complex polygons,
 represented by a series of polygonal contours.
\end_layout

\begin_layout Subsection
Operations
\end_layout

\begin_layout Standard
Comprises geometric operations such as computing intersections,
 of applying geometric transform.
\end_layout

\begin_layout Minisec
intersectLinePolygon3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectLinePolygon3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Intersection point of a 3D line and a 3D polygon.
\end_layout

\begin_layout Minisec
intersectRayPolygon3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectRayPolygon3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Intersection point of a 3D ray and a 3D polygon.
\end_layout

\begin_layout Minisec
clipPolygonByPlane3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipPolygonByPlane3d
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipping!polygon (3D)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "fun:clipPolygonByPlane3d"

\end_inset

Clips a convex 3D polygon with a 
\begin_inset Quotes eld
\end_inset

half-space
\begin_inset Quotes erd
\end_inset

 defined by a 3D plane.
 See also the function clipConvexPolyhedronByPlane 
\begin_inset CommandInset ref
LatexCommand vpageref
reference "fun:clipConvexPolyhedronByPlane"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Minisec
transformPolygon3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
transformPolygon3d
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Transform a polygon with a 3D affine transform.
\end_layout

\begin_layout Minisec
projPointOnPolyline3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout

\family roman
\series medium
\shape up
\size normal
\emph off
\nospellcheck off
\bar no
\strikeout off
\xout off
\uuline off
\uwave off
\noun off
\color none
projPointOnPolyline3d
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
projection!on polyline (3D)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the position of a 3D point projected on a 3D polyline.
\end_layout

\begin_layout Subsection
Measurements
\end_layout

\begin_layout Minisec
polygonCentroid3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonCentroid3d
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
centroid!polygon (3D)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Centroid (or center of mass) of a polygon.
\end_layout

\begin_layout Minisec
polygonArea3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygonArea3d
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
area!polygon (3D)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Area of a 3D polygon.
\end_layout

\begin_layout Minisec
polygon3dNormalAngle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polygon3dNormalAngle
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the normal angle at a vertex of the 3D polygon.
\end_layout

\begin_layout Minisec
isPolygon3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isPolygon3d
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Checks if the input is a 3D polygon.
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Subsection
Drawing functions
\end_layout

\begin_layout Minisec
drawPolygon3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawPolygon3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a 3D polygon specified by a list of vertex coords.
\end_layout

\begin_layout Minisec
fillPolygon3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fillPolygon3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Fills a 3D polygon specified by a list of vertex coords.
\end_layout

\begin_layout Subsection
3D Triangles
\end_layout

\begin_layout Standard
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
triangle (3D)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
A 3D triangle is simply defined by a triplet of 3D points.
 Within MatGeom,
 it is usually represented either as a 1-by-9 row vector,
 or as a 3-by-3 numeric array,
 where each row contains the coordinates of a single vertex.
\end_layout

\begin_layout Minisec
triangleArea3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
triangleArea3d
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
area!triangle (3D)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the area of a 3D triangle.
\end_layout

\begin_layout Minisec
distancePointTriangle3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distancePointTriangle3d
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distance!point to triangle (3D)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Comptues the minimum distance between a 3D point and a 3D triangle.
\end_layout

\begin_layout Minisec
intersectLineTriangle3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectLineTriangle3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the intersection point of a 3D line and a 3D triangle.
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
3D curves
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "sec:Curves-3D"

\end_inset


\end_layout

\begin_layout Standard
This sections describes smooth 3D curves (other than lines or line segments) that can be manipulated within the MatGeom library.
 Most curves are usually converted to 3D polyline for further computation.
\end_layout

\begin_layout Subsection
Polyline
\end_layout

\begin_layout Standard
As for 2D polygons,
 3D polylines are represented by a 
\begin_inset Formula $N\times3$
\end_inset

 numeric array containing vertex coordinates.
\end_layout

\begin_layout Minisec
drawPolyline3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawPolyline3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a 3D polyline specified by a list of vertex coordinates.
\end_layout

\begin_layout Subsection
Circles
\end_layout

\begin_layout Standard
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
circle!3D
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Circles in 3D are represented by a 1-by-7 row vector containing the coordinates of the centroid,
 the radius,
 and three Euler angles describing the orientation of the circle.
 The three angles correspond to colatitude,
 azimut,
 and rotation around normal angle (see section
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Orientation-3D-Shapes"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

circle = [x0 y0 z0 R THETA PHI PSI];
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
fitCircle3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fitCircle3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Fits a 3D circle to a set of points.
\end_layout

\begin_layout Minisec
distancePointCircle3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distancePointCircle3d
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Returns the distance between 3D points and 3D circle.
\end_layout

\begin_layout Minisec
transformCircle3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
transformCircle3d
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Transforms a 3D circle with a 3D affine transformation.
\end_layout

\begin_layout Minisec
circle3dPosition
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
circle3dPosition
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns the angular position of a point on a 3D circle.
\end_layout

\begin_layout Minisec
circle3dPoint
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
circle3dPoint
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Coordinates of a point on a 3D circle from its position.
\end_layout

\begin_layout Minisec
circle3dOrigin
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
circle3dOrigin
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns the first point of a 3D circle.
\end_layout

\begin_layout Minisec
drawCircle3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawCircle3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a 3D circle.
\end_layout

\begin_layout Minisec
drawCircleArc3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawCircleArc3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a 3D circle arc.
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Subsection
Ellipses
\end_layout

\begin_layout Standard
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
ellipse!3D
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Ellipses in 3D are represented by a 1-by-9 row vector containing the coordinates of the centroid,
 the length of the three semi-axes,
 and three Euler angles describing the orientation of the ellipse.
 The three angles correspond to colatitude,
 azimut,
 and rotation around normal angle (see section
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Orientation-3D-Shapes"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

elli = [x0 y0 z0  A B C  THETA PHI PSI];
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
fitEllipse3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fitEllipse3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Fits a 3D ellipse to a set of points.
\end_layout

\begin_layout Minisec
drawEllipse3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawEllipse3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "fun:drawEllipse3d"

\end_inset

Draws a 3D ellipse.
\end_layout

\begin_layout Section
Smooth surfaces
\end_layout

\begin_layout Standard
Several geometric surfaces can be manipulated within MatGeom.
 They include spheres,
 ellipsoids,
 cylinders,
 and revolution surfaces.
\end_layout

\begin_layout Subsection
Spheres
\end_layout

\begin_layout Standard
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
sphere
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Spheres are defined by a center and a radius.
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

sphere = [x0 y0 z0 R]
\end_layout

\end_inset


\end_layout

\begin_layout Subsubsection
Creation and intersections
\end_layout

\begin_layout Minisec
createSphere
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createSphere
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a sphere passing through 4 points.
\end_layout

\begin_layout Minisec
intersectLineSphere
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectLineSphere
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns the intersection points between a line and a sphere.
\end_layout

\begin_layout Minisec
intersectPlaneSphere
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectPlaneSphere
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns the intersection circle between a plane and a sphere.
\end_layout

\begin_layout Subsubsection
Drawing functions
\end_layout

\begin_layout Standard
Several functions are provided to draw spheres,
 or geometries defined over a sphere.
\end_layout

\begin_layout Minisec
drawSphere
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawSphere
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draws a sphere as a mesh.
\end_layout

\begin_layout Minisec
drawSphericalEdge
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawSphericalEdge
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draws an edge on the surface of a sphere.
\end_layout

\begin_layout Minisec
drawSphericalTriangle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawSphericalTriangle
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draws a triangle on a sphere.
\end_layout

\begin_layout Minisec
fillSphericalTriangle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fillSphericalTriangle
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Fills a triangle on a sphere.
\end_layout

\begin_layout Minisec
drawSphericalPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawSphericalPolygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draws a spherical polygon.
\end_layout

\begin_layout Minisec
fillSphericalPolygon
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fillSphericalPolygon
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Fills a spherical polygon.
\end_layout

\begin_layout Minisec
sphericalVoronoiDomain
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
sphericalVoronoiDomain
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes a spherical voronoi domain.
\end_layout

\begin_layout Subsection
Ellipsoids
\end_layout

\begin_layout Standard
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
ellipsoid
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Ellipsoids are a generalization of spheres,
 that are defined by a center,
 three radius,
 and three Euler angles (see Section
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "subsec:Euler-Angles"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

Elli = [x0 y0 z0 RA RB RC PHI THETA PSI]
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
equivalentEllipsoid
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
equivalentEllipsoid
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
moments!points (3D)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the ellipsoid with the same moments up to the second order as the given set of 3D points (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Equivalent-Ellipsoid"
nolink "false"

\end_inset

).
 
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/demoInertiaEllipsoid_03.png
	lyxscale 50
	width 60text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Equivalent-Ellipsoid"

\end_inset

Equivalent ellipsoid of a point cloud.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Minisec
isPointInEllipsoid
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isPointInEllipsoid
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Determines if a 3D points lies within or outside an ellipsoid.
\end_layout

\begin_layout Minisec
ellipsoidSurfaceArea
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
ellipsoidSurfaceArea
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
area!ellipsoid
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes an approximation of the surface area of an ellipsoid from the semi-axis lengths.
 The approximation formula is given by:
\begin_inset Formula 
\begin{align*}
S & \sim4\pi\cdot\left(\frac{1}{3}\left(a^{p}\cdot b^{p}+a^{p}\cdot c^{p}+b^{p}\cdot c^{p}\right)\right)^{1/p}
\end{align*}

\end_inset

with 
\begin_inset Formula $p=1.6075$
\end_inset

.
 The resulting error should be less than 
\begin_inset Formula $1.061\%$
\end_inset

.
\end_layout

\begin_layout Minisec
oblateSurfaceArea
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
oblateSurfaceArea
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the approximated surface area of an oblate ellipsoid,
 given its largest and smallest radiusses.
\end_layout

\begin_layout Minisec
prolateSurfaceArea
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
prolateSurfaceArea
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the approximated surface area of a prolate ellipsoid,
 given its largest and smallest radiusses.
\end_layout

\begin_layout Minisec
drawEllipsoid
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawEllipsoid
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a 3D ellipsoid.
 It is possible to specify color or transparency of the ellipsoid surface.
 The three orthogonal reference 3D ellipses
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout

\family roman
\series medium
\shape up
\size normal
\emph off
\nospellcheck off
\bar no
\strikeout off
\xout off
\uuline off
\uwave off
\noun off
\color none
ellipse!3D
\end_layout

\end_inset

 can also be displayed.
 See also the drawEllipse3d function (p.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand pageref
reference "fun:drawEllipse3d"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Subsection
Cylinders
\end_layout

\begin_layout Standard
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
cylinder
\end_layout

\end_inset


\end_layout

\begin_layout Standard
A cylinder is defined by two end-points and a radius.
 It is represented as a 
\begin_inset Formula $1\times7$
\end_inset

 row vector (three values for each endpoint,
 and one value for the radius).
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

Cylinder = [X1 Y1 Z1 X2 Y2 Z2 R];
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
cylinderSurfaceArea
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
cylinderSurfaceArea
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
area!cylinder
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the surface area of a cylinder,
 based on its length and radius.
\end_layout

\begin_layout Minisec
intersectLineCylinder
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectLineCylinder
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the intersection points between a line and a cylinder.
\end_layout

\begin_layout Minisec
drawCylinder
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawCylinder
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a cylinder on the current axis.
\end_layout

\begin_layout Minisec
drawEllipseCylinder
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawEllipseCylinder
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
ellipse
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "fun:drawEllipseCylinder"

\end_inset

Draws a cylinder with an ellipse cross-section.
 
\end_layout

\begin_layout Subsection
Other smooth surfaces
\end_layout

\begin_layout Standard
Other functions allow to create and draw more general surfaces.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/geom3d/torus.png
	lyxscale 50
	width 32text%

\end_inset


\begin_inset Graphics
	filename images/geom3d/capsule.png
	lyxscale 50
	width 32text%

\end_inset


\begin_inset Graphics
	filename images/geom3d/dome.png
	lyxscale 50
	width 32text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Smooth-Shapes-3D"

\end_inset

3D representation of shapes with smooth boundary.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Minisec
drawTorus
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawTorus
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
torus
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draws a torus (3D ring).
 See Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Smooth-Shapes-3D"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Minisec
drawCapsule
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawCapsule
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draws a 3D capsule,
 composed of a cylinder and two domes at the extremities.
 See Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Smooth-Shapes-3D"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Minisec
drawDome
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawDome
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draws a 3D dome,
 or half-sphere.
 See Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Smooth-Shapes-3D"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Minisec
revolutionSurface
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
revolutionSurface
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
revolution surface
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a surface of revolution from a planar curve.
 See the Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Revolution-Surface"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Minisec
surfaceCurvature
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
surfaceCurvature
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
curvature
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Curvature on a surface from angle and principal curvatures.
\end_layout

\begin_layout Minisec
drawSurfPatch
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawSurfPatch
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a 3D surface patch,
 with 2 parametrized surfaces.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/demoRevolutionSurface_01.png
	lyxscale 50
	width 60text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Revolution-Surface"

\end_inset

3D revolution surface
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
3D Transforms
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "sec:3D-Transforms"

\end_inset


\end_layout

\begin_layout Standard
Transforms in 3D space are represented by 4-by-4 matrices in homogeneous coordinates:
\begin_inset Formula 
\begin{align}
\left(\begin{array}{c}
x'\\
y'\\
z'\\
1
\end{array}\right) & =\left(\begin{array}{cccc}
m_{00} & m_{01} & m_{02} & m_{03}\\
m_{10} & m_{11} & m_{12} & m_{13}\\
m_{20} & m_{21} & m_{22} & m_{23}\\
0 & 0 & 0 & 1
\end{array}\right)\cdot\left(\begin{array}{c}
x\\
y\\
z\\
1
\end{array}\right)
\end{align}

\end_inset


\end_layout

\begin_layout Standard
The upper-left 
\begin_inset Formula $3\times3$
\end_inset

 square corresponds to the linear part of the transform,
 whereas the 
\begin_inset Formula $m_{i3}$
\end_inset

 elements correspond to the translation part.
 As for 2D transforms,
 3D transforms consider points in column vectors,
 while they are represented as row vectors within the library.
 The transform functions (such as transformPoint3d) manage the necessary transposition.
\end_layout

\begin_layout Subsection
Basic transforms
\end_layout

\begin_layout Standard
Several functions allow to create classical 3D affine transforms.
 They return 4-by-4 matrices.
\end_layout

\begin_layout Minisec
createTranslation3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createTranslation3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates the 4x4 matrix of a 3D translation.
\begin_inset Formula 
\begin{align}
T(\boldsymbol{u}) & =\left[\begin{array}{cccc}
1 & 0 & 0 & u_{x}\\
0 & 1 & 0 & u_{y}\\
0 & 0 & 1 & u_{z}\\
0 & 0 & 0 & 1
\end{array}\right]
\end{align}

\end_inset


\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

transfo = createTranslation3d(vect);
\end_layout

\begin_layout Plain Layout

transfo = createTranslation3d([vx vy vz]);
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
createScaling3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createScaling3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates the 4x4 matrix of a 3D scaling.
 The scaling parameter can be either a scalar (uniform scaling),
 or a three-element vector 
\begin_inset Formula $\boldsymbol{s}=(s_{x},s_{y},s_{z})^{t}$
\end_inset

 corresponding to the scaling along each dimension.
\end_layout

\begin_layout Standard
\begin_inset Formula 
\begin{align}
S(\boldsymbol{s}) & =\left[\begin{array}{cccc}
s_{x} & 0 & 0 & 0\\
0 & s_{y} & 0 & 0\\
0 & 0 & s_{z} & 0\\
0 & 0 & 0 & 1
\end{array}\right]
\end{align}

\end_inset


\begin_inset listings
inline false
status open

\begin_layout Plain Layout

transfo = createScaling3d(s);
\end_layout

\begin_layout Plain Layout

transfo = createScaling3d([sx sy sz]);
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
createRotationOx
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createRotationOx
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
rotation!rotation 3D
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates the 4x4 matrix of a 3D rotation around x-axis,
 by an angle given in radians.
\begin_inset Formula 
\begin{align}
R_{X}(\theta) & =\left[\begin{array}{cccc}
1 & 0 & 0 & 0\\
0 & \cos\theta & -\sin\theta & 0\\
0 & \sin\theta & \cos\theta & 0\\
0 & 0 & 0 & 1
\end{array}\right]
\end{align}

\end_inset

A rotation around the 
\begin_inset Formula $x$
\end_inset

-axis by 
\begin_inset Formula $\pi/2$
\end_inset

 will map the 
\begin_inset Formula $y$
\end_inset

-axis onto the 
\begin_inset Formula $z$
\end_inset

-axis.
 More generally,
 if the main axes are numbered such that 
\begin_inset Formula $e_{0}=e_{x}$
\end_inset

,
 
\begin_inset Formula $e_{1}=e_{y}$
\end_inset

,
 
\begin_inset Formula $e_{2}=e_{z}$
\end_inset

,
 then a rotation around axis 
\begin_inset Formula $e_{i}$
\end_inset

 will map the axis 
\begin_inset Formula $e_{(i+1)\text{mod}3}$
\end_inset

 onto the axis 
\begin_inset Formula $e_{(i+2)\text{mod}3}$
\end_inset

 .
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

transfo = createRotationOx(theta);
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
createRotationOy
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createRotationOy
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates the 4x4 matrix of a 3D rotation around y-axis,
 by an angle given in radians.
 
\end_layout

\begin_layout Standard
\begin_inset Formula 
\begin{align}
R_{Y}(\theta) & =\left[\begin{array}{cccc}
\cos\theta & 0 & \sin\theta & 0\\
0 & 1 & 0 & 0\\
-\sin\theta & 0 & \cos\theta & 0\\
0 & 0 & 0 & 1
\end{array}\right]
\end{align}

\end_inset

A rotation around the 
\begin_inset Formula $y$
\end_inset

-axis by 
\begin_inset Formula $\pi/2$
\end_inset

 will map the 
\begin_inset Formula $z$
\end_inset

-axis onto the 
\begin_inset Formula $x$
\end_inset

-axis (
\begin_inset Quotes eld
\end_inset

downwards rotation
\begin_inset Quotes erd
\end_inset

).
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

transfo = createRotationOy(theta);
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
createRotationOz
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createRotationOz
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates the 4x4 matrix of a 3D rotation around z-axis,
 by an angle given in radians.
\end_layout

\begin_layout Standard
\begin_inset Formula 
\begin{align}
R_{Z}(\theta) & =\left[\begin{array}{cccc}
\cos\theta & -\sin\theta & 0 & 0\\
\sin\theta & \cos\theta & 0 & 0\\
0 & 0 & 1 & 0\\
0 & 0 & 0 & 1
\end{array}\right]
\end{align}

\end_inset

A rotation around the 
\begin_inset Formula $z$
\end_inset

-axis by 
\begin_inset Formula $\pi/2$
\end_inset

 will map the 
\begin_inset Formula $x$
\end_inset

-axis onto the 
\begin_inset Formula $y$
\end_inset

-axis.
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

transfo = createRotationOz(theta);
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Subsection
Euler Angles and 3D rotations
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "subsec:Euler-Angles"

\end_inset


\end_layout

\begin_layout Standard
Several different conventions exist for considering 3D rotations.
 One possibility is to consider the 
\begin_inset Formula $4\times4$
\end_inset

 matrix of affine coefficients,
 but this requires to stores several coefficients,
 and there is not warranty that the transform actually corresponds to a rotation.
 A common way to summarize a 3D rotation is to represent it by a succession of three rotations along main axes,
 leading to Euler Angles.
 An alternative is to consider rotation around a 3D line by a specific angle.
\end_layout

\begin_layout Subsubsection
Euler Angles
\end_layout

\begin_layout Standard
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angle!Euler angles
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Euler Angles are defined by a series of three rotations along specific axes.
 Several definitions of Euler angles exist,
 depending on the axes and on the order rotations are performed,
 and if the rotation are performed in the global coordinate system,
 or in the coordinate system of the reference object after rotation.
\end_layout

\begin_layout Standard
The MatGeom library usually uses Euler angles defined as a series of three 
\begin_inset Quotes eld
\end_inset

global
\begin_inset Quotes erd
\end_inset

 rotations along the 
\begin_inset Formula $x$
\end_inset

-axis first,
 then along the 
\begin_inset Formula $y$
\end_inset

-axis,
 and finally along the 
\begin_inset Formula $z$
\end_inset

-axis:
\begin_inset Formula 
\begin{align}
R_{\varphi,\theta,\psi} & =R_{z}(\varphi)\cdot R_{y}(\theta)\cdot R_{x}(\psi)
\end{align}

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/geom3d/ellipsoid-angles.png
	scale 60

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Euler-Angles-Definitions"

\end_inset

Definition of 3D Euler angles.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Standard
Euler angles may be interpreted as follow (see also Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Euler-Angles-Definitions"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

):
\end_layout

\begin_layout Labeling
\labelwidthstring 00.00.0000
PHI is the azimut,
 i.e.
 the angle of the projection on horizontal plane with the Ox axis,
 with value beween 0 and 180 degrees.
\end_layout

\begin_layout Labeling
\labelwidthstring 00.00.0000
THETA is the 
\begin_inset Quotes eld
\end_inset

declination
\begin_inset Quotes erd
\end_inset

,
 i.e.
 the angle with the (xy) plane,
 with value between -90 and +90 degrees.
 Note that a positive value of 
\begin_inset Formula $\theta$
\end_inset

 corresponds to a direction that points downwards.
\end_layout

\begin_layout Labeling
\labelwidthstring 00.00.0000
PSI is the 'roll',
 i.e.
 the rotation around the (PHI,
 THETA) direction,
 with value in degrees
\end_layout

\begin_layout Standard
Note that within the MatGeom library,
 Euler angles are usually given in the order 
\begin_inset Formula $(\varphi,\theta,\psi)$
\end_inset

,
 i.e.
 in the reverse order to that they are applied.
 Moreover,
 when used for describing the 3D rotation of a shape,
 they are expressed in degrees.
 
\end_layout

\begin_layout Minisec
eulerAnglesToRotation3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
eulerAnglesToRotation3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts 3D Euler angles to 3D rotation matrix.
\end_layout

\begin_layout Minisec
rotation3dToEulerAngles
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
rotation3dToEulerAngles
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Extracts Euler angles from a rotation matrix.
 Computations are based on 
\begin_inset CommandInset citation
LatexCommand citet
key "Slabaugh_1999"
literal "false"

\end_inset

.
\end_layout

\begin_layout Subsubsection
Axis-Angle rotation
\end_layout

\begin_layout Standard
An alternative representation for a 3D representation is to consider a 3D direction (such as the direction vector of a 3D line),
 and the rotation angle around this axis.
 Within MatGeom,
 the position of the line is also taken into account to initialize the translation parameters.
\end_layout

\begin_layout Minisec
createRotation3dLineAngle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createRotation3dLineAngle
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates rotation around a line by an angle theta.
\end_layout

\begin_layout Minisec
rotation3dAxisAndAngle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
rotation3dAxisAndAngle
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Determines axis and angle of a 3D rotation matrix.
\end_layout

\begin_layout Subsubsection
Other 3D rotations
\end_layout

\begin_layout Minisec
createBasisTransform3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createBasisTransform3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes matrix for transforming a basis into another basis.
 Basis can be used to represent the position and the orientation of a 3D shape or of a 3D coordinate system different from the canonical one.
 A 3D basis is defined by an origin point (as a 
\begin_inset Formula $1\times3$
\end_inset

 row vector) and two direction vectors (each given as a 
\begin_inset Formula $1\times3$
\end_inset

 row vector).
 The basis is represented by concatenating origin point and direction vectors into a single 
\begin_inset Formula $A\times9$
\end_inset

 row vector.
 Direction vectors are expected to be orthogonal.
 
\end_layout

\begin_layout Minisec
createRotationVector3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createRotationVector3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the transform matrix corresponding to the rotation between two vectors.
\end_layout

\begin_layout Minisec
createRotationVectorPoint3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createRotationVectorPoint3d
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the transform matrix corresponding to the rotation between two vectors,
 around a specified point.
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Subsection
3D registration
\end_layout

\begin_layout Standard
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
registration
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
registerPoints3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
registerPoints3d
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the transformation matrix that will match one 3D point set onto another one.
 Two different algorithms can be chosen:
 
\begin_inset Quotes eld
\end_inset

icp
\begin_inset Quotes erd
\end_inset

 or 
\begin_inset Quotes eld
\end_inset

affine
\begin_inset Quotes erd
\end_inset

.
\end_layout

\begin_layout Minisec
registerPoints3d_icp
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
Iterated Closest Point
\end_layout

\end_inset


\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
registerPoints3d_icp
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "fun:registerPoints3d_icp"

\end_inset

Computes the rigid transform (composed of a translation and a rotation) that projects a set of points onto another one using the Iterated Closest Point (ICP) algorithm 
\begin_inset CommandInset citation
LatexCommand citep
key "Besl_1992_PAMI"
literal "false"

\end_inset

.
 Based on a previous work by Hans Martin Kjer and Jakob Wilm
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
\begin_inset Flex URL
status open

\begin_layout Plain Layout

https://www.mathworks.com/matlabcentral/fileexchange/27804-iterative-closest-point
\end_layout

\end_inset


\end_layout

\end_inset

.
 See also the registerICP function (section
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fun:registerICP"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
 See an example on Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:ICP-Example"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
 Syntax:
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

transfo = registerPoints3d_icp(srcPts,
 tgtPts,
 nIters);
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/geom3d/registerPoints3d_icp_bunny.png
	lyxscale 70
	width 75text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:ICP-Example"

\end_inset

Example of 3D rigid registration using ICP algorithm.
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\end_layout

\begin_layout Minisec
registerPoints3d_affine
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
registerPoints3d_affine
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Fits a 3D affine transform betwen two point sets using iterative algorithm.
 Syntax is similar to that of registerPoints3d_icp,
 but provides less optional arguments:
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

transfo = registerPoints3d_affine(srcPts,
 tgtPts,
 nIters);
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Subsection
Utility functions
\end_layout

\begin_layout Standard
Some functions aim at combining or processing transform matrices.
\end_layout

\begin_layout Minisec
recenterTransform3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
recenterTransform3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Changes the fixed point of an affine 3D transform.
\end_layout

\begin_layout Minisec
composeTransforms3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
composeTransforms3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Concatenates several space transformations.
\end_layout

\begin_layout Section
Drawing functions
\end_layout

\begin_layout Standard
Several functions allow to display common geometric shapes.
\end_layout

\begin_layout Subsection
Polygonal shapes
\end_layout

\begin_layout Minisec
drawCube
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawCube
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
cube
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draws a 3D centered cube,
 eventually rotated.
\end_layout

\begin_layout Minisec
drawCuboid
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawCuboid
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a 3D cuboid,
 eventually rotated.
\end_layout

\begin_layout Minisec
drawPlatform
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawPlatform
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draws a rectangular platform based on a plane.
\end_layout

\begin_layout Subsection
Drawing utilities
\end_layout

\begin_layout Minisec
drawGrid3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawGrid3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a 3D grid on the current axis.
\end_layout

\begin_layout Minisec
drawAxis3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawAxis3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a coordinate system and an origin.
\end_layout

\begin_layout Minisec
drawAxisCube
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawAxisCube
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Draws a colored cube representing axis orientation.
\end_layout

\begin_layout Minisec
drawArrow3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawArrow3d
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draws 3D arrows using a quiver plot.
\end_layout

\begin_layout Minisec
drawAngleBetweenVectors3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawAngleBetweenVectors3d
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draws a 3D circle arc between two 3D vectors.
\end_layout

\begin_layout Chapter
Module meshes3d
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "chap:meshes3d"

\end_inset


\end_layout

\begin_layout Standard
The meshes3d module provides functions for the manipulation of 3D surface meshes.
 Meshes can be composed of triangular faces (
\begin_inset Quotes eld
\end_inset

tri-mesh
\begin_inset Quotes erd
\end_inset

),
 or have faces with variable number of vertices.
 The term 
\begin_inset Quotes eld
\end_inset

polyhedron
\begin_inset Quotes erd
\end_inset

 is sometimes used to denote functions that expect as input a 3D mesh that is convex and with a low number of faces.
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
minitoc
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Quick tour
\end_layout

\begin_layout Standard
The meshes3d module provides functions for the manipulation of 3D surface meshes,
 also known as polygonal meshes.
 The library supports triangular meshes,
 quadrangular meshes,
 as well as meshes with arbitrary number of face vertices for some functions.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status collapsed

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/meshes3d/bunny/bunny1k_faceNormals.png
	width 45text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Face normals and centroids.
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status collapsed

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/meshes3d/bunny/bunny1k_curvatureMap.png
	width 45text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Map of Gaussian curvature.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout
\align center
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status collapsed

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/meshes3d/bunny/bunny1k_pointDistance.png
	width 45text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Point to mesh distance.
\end_layout

\end_inset


\end_layout

\end_inset


\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status collapsed

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/meshes3d/bunny/bunny1k_clipWithPlane.png
	width 45text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Mesh clipping with plane.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Mesh-Processing"

\end_inset

Examples of mesh processing operations.
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\end_layout

\begin_layout Standard
A large family of operations is provided,
 together with utility functions for reading,
 writing,
 visualizing meshes.
 An overview of mesh processing operations if provided on Figure
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Mesh-Processing"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Section
Mesh data representation
\end_layout

\begin_layout Subsection
Abstract data structure
\end_layout

\begin_layout Standard
Geometric processing of 3D polygonal meshes requires to take into account both the geometric information (i.e.
 the position of the vertices) and the topological information (i.e.
 the vertex and face adjacency).
 Moreover,
 mesh faces can be triangles,
 quadrilaterals,
 or more complex polygons.
 Hence,
 several abstract data types have been proposed to efficiently represent such data 
\begin_inset CommandInset citation
LatexCommand citep
key "Bieri_1991,Chen_1996,DeBerg_2000,Botsch_2010"
literal "false"

\end_inset

.
 One of the simplest ones is the face-vertex data structure:
 a first array contains vertex coordinates,
 second array contains the indices of each face vertices (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand pageref
reference "fig:Polygon-mesh-representation."
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/meshes3d/def/mesh_elements.png
	width 8cm

\end_inset


\begin_inset Graphics
	filename images/meshes3d/def/mesh_face_vertices_table.png
	lyxscale 70
	width 3cm

\end_inset


\begin_inset Note Note
status collapsed

\begin_layout Plain Layout
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="10" columns="4">
<features tabularvalignment="bottom">
<column alignment="center" valignment="top">
<column alignment="center" valignment="top">
<column alignment="center" valignment="top">
<column alignment="center" valignment="top">
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
face
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $\text{f}_{\text{v}_{1}}$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $\text{f}_{\text{v}_{2}}$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $\text{f}_{\text{v}_{3}}$
\end_inset


\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
1
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
1
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
5
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
6
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
2
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
1
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
6
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
2
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
2
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
6
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
4
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
4
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
2
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
4
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
5
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
5
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
9
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
6
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
6
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
6
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
9
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
8
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
7
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
4
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
6
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
8
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
8
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
4
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
8
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
7
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
9
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
4
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
7
\end_layout

\end_inset
</cell>
</row>
</lyxtabular>

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Polygon-mesh-representation."

\end_inset

Polygon mesh representation.
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\end_layout

\begin_layout Standard
One usually order the vertices of 3D faces in a consistent way,
 such as the outer normal of the face points outwards of the mesh.
\end_layout

\begin_layout Subsection
MatGeom data structures
\end_layout

\begin_layout Standard
Within MatGeom,
 a 3D surface mesh is represented by using (at least) two arrays:
\end_layout

\begin_layout Labeling
\labelwidthstring 00.00.0000
vertices a 
\begin_inset Formula $N_{v}\times3$
\end_inset

 array of double containing coordinates of the 
\begin_inset Formula $N_{v}$
\end_inset

 vertices
\end_layout

\begin_layout Labeling
\labelwidthstring 00.00.0000
faces an array containing the vertex indices for each face.
 For triangular meshes,
 faces are stored as a 
\begin_inset Formula $N_{f}\times3$
\end_inset

 array.
 For generic meshes with faces with variable vertex number,
 faces is stored as a cell array,
 each cell containing the array of vertex indices for corresponding face.
 Most functions try to use the vertex with lowest index as first index.
\end_layout

\begin_layout Standard
Some functions may require or return additionnal data:
\end_layout

\begin_layout Labeling
\labelwidthstring 00.00.0000
edges an additional array that contains the source and target vertex of each edge
\end_layout

\begin_layout Standard
Functions operating on meshes usually accept 
\shape italic
a minima
\shape default
 a pair of 
\family typewriter
\color gray
vertices
\family default
\color inherit
 and 
\family typewriter
\color gray
faces
\family default
\color inherit
 input arguments.
 A large number of functions also accept as first argument a Matlab structure that encapsulates the vertices,
 faces.
 Representing a mesh as a structure allows to also include additional inforamtion wuch as mesh name,
 vertex normals,
 edge-to-face relationships...
 that maybe useful or necessary for some functions.
\end_layout

\begin_layout Section
Mesh visualization
\end_layout

\begin_layout Standard
The library includes several functions to quickly display a mesh.
 Input arguments usually comprise 
\family typewriter
\color gray
vertices
\family default
\color inherit
 and 
\family typewriter
\color gray
faces
\family default
\color inherit
 arrays,
 but a mesh structure may sometimes be passed as well.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/meshes3d/drawMesh_mushroom_crop.png
	lyxscale 50
	width 50text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Draw-Mesh-With-Face-Normals"

\end_inset

Representation of a 3D polygonal mesh together with the face normals.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Minisec
drawMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawMesh
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "fun:drawMesh"

\end_inset

Draws a 3D mesh defined by vertex and face arrays (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Draw-Mesh-With-Face-Normals"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Minisec
fillMeshFaces
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
fillMeshFaces
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Fills the faces of a mesh with the specified colors.
\end_layout

\begin_layout Minisec
drawFaceNormals
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
drawFaceNormals
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Draws normal vector of each face in a mesh (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Draw-Mesh-With-Face-Normals"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Creation of meshes
\end_layout

\begin_layout Standard
The library contains many functions for generating polygonal meshes corresponding to classical polyhedra,
 such as platonic solids.
 It also provides facilities for converting from smooth surfaces.
\end_layout

\begin_layout Subsection
Platonic solids
\end_layout

\begin_layout Standard
Several functions allows creation of meshes representing classical polyhedra.
 The results are typically of the form 
\family typewriter
\color gray
[v,f]
\family default
\color inherit
,
 or 
\family typewriter
\color gray
[v,e,f]
\family default
\color inherit
,
 where 
\family typewriter
v
\family default
 is the array of vertex coordinates,
 
\family typewriter
f
\family default
 is the array of face vertex indices,
 and 
\family typewriter
e
\family default
 is the array of edge vertex indices.
 Number of vertices,
 faces and edges for each polyhedron are given in Table
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "tab:Polyhedra-Data"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

 (p.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand pageref
reference "tab:Polyhedra-Data"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Minisec
createCube
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createCube
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
cube
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a 3D mesh representing the unit cube (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Platonic-Solids"
nolink "false"

\end_inset

-a).
\end_layout

\begin_layout Minisec
createOctahedron
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createOctahedron
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
octahedron
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a 3D mesh representing an octahedron (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Platonic-Solids"
nolink "false"

\end_inset

-b).
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/meshes3d/cube.png
	lyxscale 25
	width 24text%

\end_inset


\begin_inset Graphics
	filename images/meshes3d/octahedron.png
	lyxscale 25
	width 24text%

\end_inset


\begin_inset Graphics
	filename images/meshes3d/icosahedron.png
	lyxscale 25
	width 24text%

\end_inset


\end_layout

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/meshes3d/dodecahedron.png
	lyxscale 25
	width 24text%

\end_inset


\begin_inset Graphics
	filename images/meshes3d/tetrahedron.png
	lyxscale 25
	width 24text%

\end_inset


\begin_inset Graphics
	filename images/meshes3d/soccerBall.png
	lyxscale 25
	width 24text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Platonic-Solids"

\end_inset

The five platonic solids and a soccer ball represented as 3D meshes.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Minisec
createIcosahedron
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createIcosahedron
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a 3D mesh representing an Icosahedron (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Platonic-Solids"
nolink "false"

\end_inset

-c).
\end_layout

\begin_layout Minisec
createDodecahedron
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createDodecahedron
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a 3D mesh representing a dodecahedron (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Platonic-Solids"
nolink "false"

\end_inset

-d).
\end_layout

\begin_layout Minisec
createTetrahedron
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createTetrahedron
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a 3D mesh representing a tetrahedron (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Platonic-Solids"
nolink "false"

\end_inset

-e).
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Subsection
Other classical polyhedra
\end_layout

\begin_layout Standard
Other classical (non platonic) polyhedra can be easily generated.
 For some of them,
 number of vertices,
 faces and edges are given in Table
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "tab:Polyhedra-Data"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

 (p.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand pageref
reference "tab:Polyhedra-Data"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Minisec
createSoccerBall
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createSoccerBall
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a 3D mesh representing a soccer ball (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Platonic-Solids"
nolink "false"

\end_inset

-f).
 It can be seen as a truncated icosahedron.
\end_layout

\begin_layout Minisec
createCubeOctahedron
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createCubeOctahedron
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a 3D mesh representing a cube-octahedron (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Other-Sample-Polyhedra"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-a).
\end_layout

\begin_layout Minisec
createTetrakaidecahedron
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createTetrakaidecahedron
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a 3D mesh representing a tetrakaidecahedron (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Other-Sample-Polyhedra"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-b).
 It can be seen as a truncated tetraedra.
\end_layout

\begin_layout Minisec
createRhombododecahedron
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createRhombododecahedron
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a 3D mesh representing a rhombododecahedron (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Other-Sample-Polyhedra"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-c).
 This mesh is composed of twelve identical faces,
 but vertices do not all have the same number of vertices.
\end_layout

\begin_layout Minisec
createStellatedMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createStellatedMesh
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Replaces each face of a mesh by a pyramid.
\end_layout

\begin_layout Minisec
createDurerPolyhedron
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createDurerPolyhedron
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a mesh corresponding to the polyhedron represented in Durer's "Melancholia" (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Other-Sample-Polyhedra"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

-d).
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/meshes3d/cubeOctahedron.png
	lyxscale 25
	width 24text%

\end_inset


\begin_inset Graphics
	filename images/meshes3d/tetrakaidecahedron.png
	lyxscale 25
	width 24text%

\end_inset


\begin_inset Graphics
	filename images/meshes3d/rhombododecahedron.png
	lyxscale 25
	width 24text%

\end_inset


\begin_inset Graphics
	filename images/meshes3d/durerPolyhedron.png
	lyxscale 25
	width 24text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Other-Sample-Polyhedra"

\end_inset

Additional polyhedra that can be generated from the 
\begin_inset Quotes eld
\end_inset

meshes3d
\begin_inset Quotes erd
\end_inset

 module.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Float table
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="11" columns="6">
<features tabularvalignment="middle">
<column alignment="center" valignment="top">
<column alignment="center" valignment="top">
<column alignment="center" valignment="top">
<column alignment="center" valignment="top">
<column alignment="center" valignment="top">
<column alignment="center" valignment="top">
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
polyhedon
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
#vertices
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
#faces
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
#edges
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
#vertex per face
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
comment
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
tetrahedron
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
4
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
4
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
6
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Platonic
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
cube
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
8
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
6
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
12
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
4
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Platonic
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
octahedron
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
6
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
8
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
12
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Platonic
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
icosahedron
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
12
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
20
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
30
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Platonic
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
dodecahedron
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
20
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
12
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
30
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
5
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Platonic
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
soccer ball
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
60
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
32
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
90
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
5 or 6
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
cube-octahedron
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
12
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
14
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
24
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3 or 4
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
tetrakaidecahedron
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
24
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
14
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
36
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
4 or 6
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
rhombododecahedron
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
14
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
12
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
24
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
4
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Durer polyhedron
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
12
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
8
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
18
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3 or 6
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\end_layout

\end_inset
</cell>
</row>
</lyxtabular>

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "tab:Polyhedra-Data"

\end_inset

Number of vertices and faces of polyhedra provided by MatGeom.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Subsection
Conversion from smooth surface models
\end_layout

\begin_layout Standard
It is often convenient to convert a geometrical 3D model (cylinder,
 ellipsoid...) with known parameters into a discretized version represented by a mesh.
\end_layout

\begin_layout Minisec
cylinderMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
cylinderMesh
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
cylinder!mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a 3D mesh representing a cylinder.
\end_layout

\begin_layout Minisec
sphereMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
sphereMesh
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
sphere!mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a 3D mesh representing a sphere.
\end_layout

\begin_layout Minisec
circleMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
circleMesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Create a mesh defined by a 3D circle.
\end_layout

\begin_layout Minisec
ellipsoidMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
ellipsoidMesh
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
ellipsoid!mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Converts a 3D ellipsoid to face-vertex mesh representation.
\end_layout

\begin_layout Minisec
torusMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
torusMesh
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
torus!mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a 3D mesh representing a torus.
\end_layout

\begin_layout Minisec
curveToMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
curveToMesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a mesh surrounding a 3D curve (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:CurveToMesh"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Minisec
surfToMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
surfToMesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Converts surface grids into face-vertex mesh.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/meshes3d/trefoilKnot.png
	lyxscale 50
	width 60text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:CurveToMesh"

\end_inset

Application of the curveToMesh function
\begin_inset Note Note
status open

\begin_layout Plain Layout
update figure to add more shapes.
\end_layout

\begin_layout Plain Layout
[ sphereBasic sphereOctahedron sphereIcosahedron]
\end_layout

\begin_layout Plain Layout
[
\begin_inset space \space{}
\end_inset

ellipsoid torus knot]
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage clearpage
\end_inset


\end_layout

\begin_layout Subsection
Other creation functions
\end_layout

\begin_layout Standard
Various utilities to create meshes from various kind of inputs arguments.
\end_layout

\begin_layout Minisec
boxToMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
boxToMesh
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts a box into a quad mesh with the same size.
\end_layout

\begin_layout Minisec
triangulatePolygonPair3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
triangulatePolygonPair3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes triangulation between a pair of 3D polygons (See Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Other-Mesh-Creation"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
 Useful to reconstruct 3D meshes from polygon delineated from parallel serial sections.
 Algorithm is based on 
\begin_inset CommandInset citation
LatexCommand citet
key "Fuchs_1977_GIP"
literal "false"

\end_inset

.
\end_layout

\begin_layout Minisec
triangulatePolygonPair
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
triangulatePolygonPair
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes triangulation between a pair of 3D closed curves.
 Corresponds to an older version of the triangulatePolygonPair3d function.
\end_layout

\begin_layout Minisec
triangulateCurvePair
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
triangulateCurvePair
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes triangulation between a pair of 3D open curves (polylines).
\end_layout

\begin_layout Minisec
minConvexHull
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
minConvexHull
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
convex hull
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Returns the unique minimal convex hull of a set of 3D points.
 It consists in merging the triangular coplanar faces of the convex hull,
 resulting in a mesh composed of polygonal faces with various numbers of vertices.
\end_layout

\begin_layout Minisec
createMengerSponge
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
createMengerSponge
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Creates a cube with an inside cross removed.
 Can be used to test algorithms on meshes with complex topology.
\end_layout

\begin_layout Minisec
steinerPolytope
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
steinerPolytope
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Creates a steiner polytope from a set of vectors.
 Example (See Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Other-Mesh-Creation"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

):
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

vecList = [1 0 0;
 0 1 0;
 0 0 1;
 1 1 1];
\end_layout

\begin_layout Plain Layout

[v,
 f] = steinerPolytope(vecList);
\end_layout

\begin_layout Plain Layout

figure;
 drawMesh(v,
 f);
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/meshes3d/triangulatePolygonPair3d_square_star.png
	lyxscale 60
	width 40text%

\end_inset


\begin_inset Graphics
	filename images/meshes3d/steinerPolytope.png
	lyxscale 50
	width 40text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Other-Mesh-Creation"

\end_inset

Other mesh creation functions:
 triangulation of polygon pairs,
 computation of the Steiner polytope obtained from four 3D vectors.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage clearpage
\end_inset


\end_layout

\begin_layout Section
Mesh processing 
\end_layout

\begin_layout Standard
Most functions in this section transform a mesh into another mesh,
 or into another geometric data structure.
 Some of the functions have been adapted from the GP Toolbox library 
\begin_inset CommandInset citation
LatexCommand citep
key "gptoolbox"
literal "false"

\end_inset

.
\end_layout

\begin_layout Subsection
Filtering of meshes
\end_layout

\begin_layout Standard
Several functions allows for smoothing or simplifying meshes.
 In general,
 resulting meshes may be returned either as a pair of vertices-faces output arguments,
 or as a Matlab structure encapsulating these two data.
\end_layout

\begin_layout Minisec
smoothMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
smoothMesh
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
smoothing!mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Smoothes mesh by replacing each vertex by the average of its neighbors.
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

[v2,
 f2] = smoothMesh(v,
 f);
\end_layout

\begin_layout Plain Layout

[v2,
 f2] = smoothMesh(mesh);
\end_layout

\begin_layout Plain Layout

mesh2 = smoothMesh(...);
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
meshVertexClustering
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshVertexClustering
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
simplification!mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Simplifies a mesh using vertex clustering.
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

[v2,
 f2] = meshVertexClustering(v,
 f,
 spacing);
\end_layout

\begin_layout Plain Layout

[v2,
 f2] = meshVertexClustering(mesh,
 spacing);
\end_layout

\begin_layout Plain Layout

mesh2 = meshVertexClustering(...);
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
concatenateMeshes
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
concatenateMeshes
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Concatenates two meshes,
 by concatenating the vertex and face arrays and updating the face indices accordingly.
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

[V,
 F] = concatenateMeshes(V1,
 F1,
 V2,
 F2);
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
splitMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
splitMesh
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
connected components!mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Returns the connected components of a mesh.
\begin_inset Note Note
status open

\begin_layout Plain Layout
rename to as 
\begin_inset Quotes eld
\end_inset

meshConnectedComponents
\begin_inset Quotes erd
\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

meshes = splitMesh(vertices,
 faces);
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
subdivideMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
subdivideMesh
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Subdivides each face of the mesh.
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

[v2,
 f2] = subdivideMesh(v,
 f,
 nDivs);
\end_layout

\begin_layout Plain Layout

[v2,
 f2] = subdivideMesh(mesh,
 nDivs);
\end_layout

\begin_layout Plain Layout

mesh2 = subdivideMesh(...);
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
triangulateMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
triangulateMesh
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
triangulation!mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Converts a non-triangle mesh into a triangle mesh.
 Simple wrapper for the triangulateFaces function,
 but uses mesh data structure as input and output.
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

mesh = createCube;
\end_layout

\begin_layout Plain Layout

mesh2 = triangulateMesh(mesh);
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
triangulateFaces
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
triangulateFaces
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Converts non triangular face array into an array of triangular faces.
 Input face array may be either a 
\begin_inset Formula $n_{f}\times3$
\end_inset

 numeric array,
 a 
\begin_inset Formula $n_{f}\times4$
\end_inset

 numeric array,
 or a cell array or row vectors.
 The result is a 
\begin_inset Formula $n_{f}\times3$
\end_inset

 numeric array.
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

[v,
 f] = createCube;
\end_layout

\begin_layout Plain Layout

f2 = triangulateFaces(f);
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
reverseMeshFaceOrientation
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout

\family roman
\series medium
\shape up
\size normal
\emph off
\nospellcheck off
\bar no
\strikeout off
\xout off
\uuline off
\uwave off
\noun off
\color none
reverseMeshFaceOrientation
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
orientation!mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Reverses the normal of each face within the mesh.
 In case of boundary-free mesh,
 the volume enclosed by the resulting mesh becomes the opposite of that of the original mesh.
\end_layout

\begin_layout Minisec
mergeCoplanarFaces
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
mergeCoplanarFaces
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Merges coplanar faces of a polyhedral mesh.
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

[v2,
 f2] = mergeCoplanarFaces(v,
 f,
 tol);
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
trimMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
trimMesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Reduces the memory footprint of a polygonal mesh by removing vertices that are not referenced by any face,
 and recomputing indices of remaining vertices.
\end_layout

\begin_layout Subsection
Intersection and clipping
\end_layout

\begin_layout Standard
Can identify and select elements of the mesh that intersect other primitives,
 or that are contained within a region.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/meshes3d/demoIntersectLineMesh3d_03.png
	lyxscale 70
	width 45text%

\end_inset


\begin_inset Graphics
	filename images/meshes3d/demoIntersectPlaneMesh_03.png
	lyxscale 70
	width 45text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Intersect-Mesh-Line-Plane"

\end_inset

Intersection of a 3D polygonal mesh with a collection of lines,
 or a collection of planes.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Minisec
intersectLineMesh3d
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectLineMesh3d
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "intersectLineMesh3d"

\end_inset

Intersection points of a 3D line with a mesh (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Intersect-Mesh-Line-Plane"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
\end_layout

\begin_layout Minisec
intersectPlaneMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
intersectPlaneMesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the polygons resulting from plane-mesh intersection (Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Intersect-Mesh-Line-Plane"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
 The result is given as a cell array,
 containing one polygon per cell.
 See also the 
\begin_inset Quotes eld
\end_inset

mesh_xsections
\begin_inset Quotes erd
\end_inset

 contribution
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
Yury (2023).
 mesh_xsections (
\begin_inset Flex URL
status open

\begin_layout Plain Layout

https://github.com/caiuspetronius/mesh_xsections
\end_layout

\end_inset

),
 GitHub.
 Retrieved July 4,
 2023.
\end_layout

\end_inset

.
\end_layout

\begin_layout Minisec
polyhedronSlice
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polyhedronSlice
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Intersects a convex polyhedron with a plane.
\end_layout

\begin_layout Minisec
clipMeshVertices
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipMeshVertices
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipping!mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Clips vertices of a surface mesh and remove outer faces.
\end_layout

\begin_layout Minisec
clipConvexPolyhedronByPlane
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipConvexPolyhedronByPlane
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "fun:clipConvexPolyhedronByPlane"

\end_inset

Clips a convex polyhedron by a plane.
 See also the function clipPolygonByPlane3d 
\begin_inset CommandInset ref
LatexCommand vpageref
reference "fun:clipPolygonByPlane3d"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Minisec
cutMeshByPlane
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
cutMeshByPlane
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Cuts a mesh by a plane.
 Example:
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

% create triangulated mesh,
 and a plane from origin and normal vector
\end_layout

\begin_layout Plain Layout

[v,
 f] = createSoccerBall;
 f = triangulateFaces(f);
\end_layout

\begin_layout Plain Layout

plane = createPlane([-0.2 0 0],
 [-1 0 -1]);
\end_layout

\begin_layout Plain Layout

% split the different parts of the mesh
\end_layout

\begin_layout Plain Layout

[above,
 inside,
 below] = cutMeshByPlane(mesh,
 plane);
\end_layout

\begin_layout Plain Layout

% draw the different parts
\end_layout

\begin_layout Plain Layout

figure('color','w');
 axis equal;
 hold on;
 view(3) 
\end_layout

\begin_layout Plain Layout

drawMesh(above,
 'FaceColor',
 'r');
\end_layout

\begin_layout Plain Layout

drawMesh(inside,
 'FaceColor',
 'g');
\end_layout

\begin_layout Plain Layout

drawMesh(below,
 'FaceColor',
 'b');
\end_layout

\begin_layout Plain Layout

drawPlane3d(plane,
 'FaceAlpha',.7)
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/meshes3d/cutMeshByPlane_crop.png
	lyxscale 50
	width 60text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Illustration of the 
\begin_inset Quotes eld
\end_inset

cutMeshByPlane
\begin_inset Quotes erd
\end_inset

 function.
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\end_layout

\begin_layout Minisec
clipMeshByPlane
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipMeshByPlane
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
clipping!mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Clips a mesh by a plane.
\end_layout

\begin_layout Subsection
Generic operations
\end_layout

\begin_layout Minisec
averageMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
averageMesh
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes an average mesh from a list of meshes.
 
\end_layout

\begin_layout Subsection
Mesh repairing
\end_layout

\begin_layout Standard
Some (low-level) functions for removing topological inconsistencies and trying to obtain a manifold mesh.
\end_layout

\begin_layout Minisec
isManifoldMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isManifoldMesh
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Checks whether the input mesh may be considered as manifold.
 A mesh is a manifold if all edges are connected to either two or one faces.
 Boundary edges should also form a 3D linear ring (in some cases,
 they may form several rings).
\end_layout

\begin_layout Minisec
ensureManifoldMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
ensureManifoldMesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Applies several simplification to obtain a manifold mesh.
\end_layout

\begin_layout Minisec
removeDuplicateVertices
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
removeDuplicateVertices
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Remove duplicate vertices of a mesh.
\end_layout

\begin_layout Minisec
removeUnreferencedVertices
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
removeUnreferencedVertices
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Remove unreferenced vertices of a mesh.
\end_layout

\begin_layout Minisec
removeDuplicateFaces
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
removeDuplicateFaces
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Removes duplicate faces in a face array.
\end_layout

\begin_layout Minisec
removeMeshEars
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
removeMeshEars
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Removes the vertices that are connected to only one face.
\end_layout

\begin_layout Minisec
removeInvalidBorderFaces
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
removeInvalidBorderFaces
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Removes faces whose edges are connected to 3,
 3,
 and 1 faces.
\end_layout

\begin_layout Minisec
collapseEdgesWithManyFaces
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
collapseEdgesWithManyFaces
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Removes mesh edges adjacent to more than two faces.
\end_layout

\begin_layout Subsection
Mesh basic edition
\end_layout

\begin_layout Standard
Some low-level functions to modify a mesh.
\end_layout

\begin_layout Minisec
removeMeshVertices
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
removeMeshVertices
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Removes vertices and associated faces from a mesh.
\end_layout

\begin_layout Minisec
mergeMeshVertices
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
mergeMeshVertices
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Merges two vertices and removes eventual degenerated faces.
\end_layout

\begin_layout Minisec
removeMeshFaces
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
removeMeshFaces
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Removes faces from a mesh by face indices.
\end_layout

\begin_layout Section
Information on meshes
\end_layout

\begin_layout Subsection
Mesh topology
\end_layout

\begin_layout Standard
Low level functions for investigating the topology of meshes.
\end_layout

\begin_layout Subsubsection
Elements adjacency
\end_layout

\begin_layout Minisec
meshFace
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshFace
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Returns the vertex indices of a face in a mesh.
 Can be used to work on meshes with triangular or polygonal faces in a more consistent way.
\end_layout

\begin_layout Minisec
meshFaceEdges
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshFaceEdges
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes edge indices of each face.
\end_layout

\begin_layout Minisec
meshFaceNumber
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshFaceNumber
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns the number of faces in this mesh.
\end_layout

\begin_layout Minisec
meshEdges
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshEdges
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes array of edge vertex indices from face array.
\end_layout

\begin_layout Minisec
meshEdgeFaces
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshEdgeFaces
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes index of faces adjacent to each edge of a mesh.
\end_layout

\begin_layout Minisec
trimeshEdgeFaces
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
trimeshEdgeFaces
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes index of faces adjacent to each edge of a triangular mesh.
\end_layout

\begin_layout Minisec
meshFaceAdjacency
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshFaceAdjacency
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes adjacency list of face around each face.
\end_layout

\begin_layout Minisec
meshAdjacencyMatrix
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshAdjacencyMatrix
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the adjacency matrix of a mesh from set of faces.
\end_layout

\begin_layout Minisec
checkMeshAdjacentFaces
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
checkMeshAdjacentFaces
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Checks if adjacent faces of a mesh have similar orientation.
\end_layout

\begin_layout Minisec
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/meshes3d/def/mesh_boundary_vertexRing.png
	width 50text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "fig:Boundary_VertexRing"

\end_inset

Topological information about a mesh.
 Mesh boundary edges (thick blue).
 Vertex Ring of the red vertex (thick red).
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Minisec
meshVertexRing
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout

\family roman
\series medium
\shape up
\size normal
\emph off
\nospellcheck off
\bar no
\strikeout off
\xout off
\uuline off
\uwave off
\noun off
\color none
meshVertexRing
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the ring around the vertex of a mesh,
 i.e.
 the indices of the vertex that are connected around that vertex (See Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Boundary_VertexRing"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
 For regular vertices,
 the vertex ring forms either a loop or an open polyline (for vertices located on the boundary of the mesh).
\end_layout

\begin_layout Subsubsection
Mesh boundary
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout

\family roman
\series medium
\shape up
\size normal
\emph off
\nospellcheck off
\bar no
\strikeout off
\xout off
\uuline off
\uwave off
\noun off
\color none
boundary!mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
The boundary of a mesh corresponds to the set of edges that are adjacent to only one face of the mesh (See Fig.
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "fig:Boundary_VertexRing"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

).
 A mesh does not necessarily have a boundary (e.g.
 all the meshes that completely enclose a bounded volume).
\end_layout

\begin_layout Minisec
meshBoundaryEdges
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshBoundaryEdges
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Determines the boundary edges of a mesh.
 Returns the results as a collection of 3D line strings.
 Rewritten from function is_boundary_facet.m by Alec Jacobson
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
\begin_inset Flex URL
status open

\begin_layout Plain Layout

https://github.com/alecjacobson/gptoolbox
\end_layout

\end_inset


\end_layout

\end_inset

.
 
\end_layout

\begin_layout Minisec
meshBoundaryEdgeIndices
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout

\family roman
\series medium
\shape up
\size normal
\emph off
\nospellcheck off
\bar no
\strikeout off
\xout off
\uuline off
\uwave off
\noun off
\color none
meshBoundaryEdgeIndices
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Returns the indices of boundary edges of a mesh.
\end_layout

\begin_layout Minisec
meshBoundaryVertexIndices
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout

\family roman
\series medium
\shape up
\size normal
\emph off
\nospellcheck off
\bar no
\strikeout off
\xout off
\uuline off
\uwave off
\noun off
\color none
meshBoundaryVertexIndices
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Returns the indices of boundary vertices of a mesh.
\end_layout

\begin_layout Subsection
Summary geometries
\end_layout

\begin_layout Standard
It is often useful to consider a simpler shape that summarizes some of the features of the mesh.
 Note that summary geometries may also be computed on the point set corresponding to mesh vertices.
\end_layout

\begin_layout Minisec
meshCentroid
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout

\family roman
\series medium
\shape up
\size normal
\emph off
\nospellcheck off
\bar no
\strikeout off
\xout off
\uuline off
\uwave off
\noun off
\color none
meshCentroid
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
centroid!mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the centroid of the input mesh.
 The mesh is not necessarily convex.
\end_layout

\begin_layout Minisec
polyhedronCentroid
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polyhedronCentroid
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the centroid of a 3D convex polyhedron.
\end_layout

\begin_layout Minisec
meshEquivalentEllipsoid
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout

\family roman
\series medium
\shape up
\size normal
\emph off
\nospellcheck off
\bar no
\strikeout off
\xout off
\uuline off
\uwave off
\noun off
\color none
meshEquivalentEllipsoid
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
ellipsoid!of a mesh
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
moments!mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Comptes the equivalent ellipsoid with same moments as the given mesh.
\end_layout

\begin_layout Subsection
Geometric measures
\end_layout

\begin_layout Standard
Several functions allows to measure 3D intrinsic volumes,
 corresponding to volume,
 surface area,
 Euler number,
 or mean breadth (proportionnal to the integral of mean curvature along mesh).
 Some functions are dedicated to specific mesh types.
\end_layout

\begin_layout Minisec
meshSurfaceArea
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshSurfaceArea
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
area!mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Surface area of a polyhedral mesh.
\end_layout

\begin_layout Minisec
trimeshSurfaceArea
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
trimeshSurfaceArea
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
area!triangle mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Surface area of a triangular mesh (should be faster than the generic function 
\begin_inset Quotes eld
\end_inset

meshSurfaceArea
\begin_inset Quotes erd
\end_inset

).
\end_layout

\begin_layout Minisec
meshVolume
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshVolume
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Volume of the space enclosed by a polygonal mesh.
\end_layout

\begin_layout Minisec
tetrahedronVolume
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
tetrahedronVolume
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Computes the signed volume of a tetrahedron.
 
\end_layout

\begin_layout Minisec
polyhedronMeanBreadth
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polyhedronMeanBreadth
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Mean breadth of a convex polyhedron.
\end_layout

\begin_layout Minisec
trimeshMeanBreadth
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
trimeshMeanBreadth
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Mean breadth of a triangular mesh.
\end_layout

\begin_layout Subsection
Geometric measures for mesh elements
\end_layout

\begin_layout Standard
Functions described here provides geometric measurements for mesh vertices,
 faces,
 or edges.
 In most cases,
 the index of the query elements can be specified.
 Otherwise,
 measure is computed for all elements within the mesh.
\end_layout

\begin_layout Minisec
meshFaceAreas
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshFaceAreas
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Surface area of each face of a mesh.
\end_layout

\begin_layout Minisec
meshFaceNormals
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshFaceNormals
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the normal vector of faces in a 3D mesh.
\end_layout

\begin_layout Minisec
meshVertexNormals
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshVertexNormals
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the normals to a mesh vertices.
\end_layout

\begin_layout Minisec
meshEdgeLength
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshEdgeLength
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Lengths of edges of a polygonal or polyhedral mesh.
\end_layout

\begin_layout Minisec
meshDihedralAngles
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshDihedralAngles
\end_layout

\end_inset

 
\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angle!mesh edge
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Dihedral angle at edges of a polyhedal mesh.
\end_layout

\begin_layout Minisec
meshCurvatures
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout

\family roman
\series medium
\shape up
\size normal
\emph off
\nospellcheck off
\bar no
\strikeout off
\xout off
\uuline off
\uwave off
\noun off
\color none
meshCurvatures
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
curvature!mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the principal curvatures for each vertex of a mesh.
\end_layout

\begin_layout Minisec
meshFacePolygons
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
meshFacePolygons
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Returns the set of polygons that constitutes a mesh.
\end_layout

\begin_layout Minisec
polyhedronNormalAngle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
polyhedronNormalAngle
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
angle!mesh vertex
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the normal angle at a vertex of a 3D polyhedron.
\end_layout

\begin_layout Subsection
Point positions
\end_layout

\begin_layout Standard
Describes the relative position of a 3D points with respect to the input mesh.
\end_layout

\begin_layout Minisec
isPointInMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
isPointInMesh
\end_layout

\end_inset

 
\end_layout

\begin_layout Standard
Checks if a point is inside a 3D mesh.
\end_layout

\begin_layout Minisec
distancePointMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distancePointMesh
\end_layout

\end_inset


\begin_inset Index gen
range none
pageformat default
status collapsed

\begin_layout Plain Layout
distance!point to mesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Computes the shortest distance between a (3D) point and a triangle mesh.
 Non triangular meshes can be converted via the 
\family typewriter
triangulateFaces
\family default
 function.
 Uses algorithm presented in 
\begin_inset CommandInset citation
LatexCommand citet
key "Eberly_1999"
literal "false"

\end_inset

.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout
\align center
\begin_inset Graphics
	filename images/meshes3d/distancePointMesh/distancePointMesh_dodecahedron_view3d.png
	lyxscale 50
	width 60text%

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Computation of distances between points and mesh.
 For each point within the horizontal slice,
 the closest distance to the polyhedron (here a dodecahedron) is computed,
 and represented with color code.
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Reading and writing meshes
\end_layout

\begin_layout Standard
This sections first lists the I/O functions dedicated to meshes,
 then gives more details about specific formats.
\end_layout

\begin_layout Subsection
General functions
\end_layout

\begin_layout Standard
The template of functions for reading (or writing) meshes is readMesh_XXX (or writeMesh_XXX),
 where XXX corresponds to the format used.
\end_layout

\begin_layout Minisec
readMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
readMesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Reads mesh data by automatically inferring the file format.
\end_layout

\begin_layout Minisec
writeMesh
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
writeMesh
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Writes mesh data to a file by automatically inferring the file format.
\end_layout

\begin_layout Subsection
OFF format
\end_layout

\begin_layout Standard
The OFF file format allows for storing polygonal mesh in a simple way
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
\begin_inset Flex URL
status open

\begin_layout Plain Layout

https://en.wikipedia.org/wiki/OFF_(file_format)
\end_layout

\end_inset


\end_layout

\end_inset

.
 Information are stored in an ASCII file,
 without compression,
 with optional color information.
\end_layout

\begin_layout Standard
A standard OFF file is composed as follows:
\end_layout

\begin_layout Itemize
First line contains the OFF string to mark the file type
\end_layout

\begin_layout Itemize
Second line contains the number of vertices,
 the number of faces,
 and optionnally the number of edges
\end_layout

\begin_layout Itemize
Comments can be provided by starting the line with the hash symbol (
\begin_inset Quotes eld
\end_inset

#
\begin_inset Quotes erd
\end_inset

)
\end_layout

\begin_layout Itemize
The vertices are specified by their three coordinates
\end_layout

\begin_layout Itemize
The faces are specified by 1) the number of vertices of the face followed by the 0-based indices of the vertices.
\end_layout

\begin_layout Itemize
Additional optional color information can be provided for faces.
\end_layout

\begin_layout Standard
An example of a simple OFF file:
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

OFF
\end_layout

\begin_layout Plain Layout

#
\end_layout

\begin_layout Plain Layout

#  cube.off
\end_layout

\begin_layout Plain Layout

#  A cube.
\end_layout

\begin_layout Plain Layout

#  There is extra RGBA color information specified for the faces.
\end_layout

\begin_layout Plain Layout

8 6 12
\end_layout

\begin_layout Plain Layout

  1.632993   0.000000   1.154701
\end_layout

\begin_layout Plain Layout

  0.000000   1.632993   1.154701
\end_layout

\begin_layout Plain Layout

 -1.632993   0.000000   1.154701
\end_layout

\begin_layout Plain Layout

  0.000000  -1.632993   1.154701
\end_layout

\begin_layout Plain Layout

  1.632993   0.000000  -1.154701
\end_layout

\begin_layout Plain Layout

  0.000000   1.632993  -1.154701
\end_layout

\begin_layout Plain Layout

 -1.632993   0.000000  -1.154701
\end_layout

\begin_layout Plain Layout

  0.000000  -1.632993  -1.154701
\end_layout

\begin_layout Plain Layout

  4  0 1 2 3  1.000 0.000 0.000 0.75
\end_layout

\begin_layout Plain Layout

  4  7 4 0 3  0.300 0.400 0.000 0.75
\end_layout

\begin_layout Plain Layout

  4  4 5 1 0  0.200 0.500 0.100 0.75
\end_layout

\begin_layout Plain Layout

  4  5 6 2 1  0.100 0.600 0.200 0.75
\end_layout

\begin_layout Plain Layout

  4  3 2 6 7  0.000 0.700 0.300 0.75
\end_layout

\begin_layout Plain Layout

  4  6 5 4 7  0.000 1.000 0.000 0.75
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
readMesh_off
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
readMesh_off
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Reads mesh data stored in OFF format.
\end_layout

\begin_layout Minisec
writeMesh_off
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
writeMesh_off
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Writes a mesh into a text file in OFF format.
\end_layout

\begin_layout Subsection
Polygon format (PLY)
\end_layout

\begin_layout Standard
The 
\begin_inset Quotes eld
\end_inset

Polygon File Format
\begin_inset Quotes erd
\end_inset

,
 or 
\begin_inset Quotes eld
\end_inset

Stanford triangle format
\begin_inset Quotes erd
\end_inset

,
 is more general and more widely used than the OFF format
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
\begin_inset Flex URL
status open

\begin_layout Plain Layout

https://en.wikipedia.org/wiki/PLY_(file_format)
\end_layout

\end_inset


\end_layout

\end_inset

.
 It allows to store a variety of properties such as face color or transparency,
 surface normals,
 texture coordinates...
 MatGeom supports reading and writing only vertex coordinates and face vertex data.
\end_layout

\begin_layout Standard
An example of a simple file in the PLY format is given below.
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

ply
\end_layout

\begin_layout Plain Layout

format ascii 1.0
\end_layout

\begin_layout Plain Layout

comment written with Matlab
\end_layout

\begin_layout Plain Layout

element vertex 8
\end_layout

\begin_layout Plain Layout

property float x
\end_layout

\begin_layout Plain Layout

property float y
\end_layout

\begin_layout Plain Layout

property float z
\end_layout

\begin_layout Plain Layout

element face 6
\end_layout

\begin_layout Plain Layout

property list uchar int vertex_index
\end_layout

\begin_layout Plain Layout

end_header
\end_layout

\begin_layout Plain Layout

-1 -1 -1
\end_layout

\begin_layout Plain Layout

1 -1 -1
\end_layout

\begin_layout Plain Layout

1 1 -1
\end_layout

\begin_layout Plain Layout

-1 1 -1
\end_layout

\begin_layout Plain Layout

-1 -1 1
\end_layout

\begin_layout Plain Layout

1 -1 1
\end_layout

\begin_layout Plain Layout

1 1 1
\end_layout

\begin_layout Plain Layout

-1 1 1
\end_layout

\begin_layout Plain Layout

4 0 1 2 3
\end_layout

\begin_layout Plain Layout

4 5 4 7 6
\end_layout

\begin_layout Plain Layout

4 6 2 1 5
\end_layout

\begin_layout Plain Layout

4 3 7 4 0
\end_layout

\begin_layout Plain Layout

4 7 3 2 6
\end_layout

\begin_layout Plain Layout

4 5 1 0 4
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
readMesh_ply
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
readMesh_ply
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Reads mesh data stored in PLY (Stanford triangle) format.
 Based on previous work by Pascal Getreuer and Gabriel Peyré 
\begin_inset CommandInset citation
LatexCommand citep
key "Peyre_2024"
literal "false"

\end_inset

.
 Supports ascii and binary formats.
\end_layout

\begin_layout Minisec
writeMesh_ply
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
writeMesh_ply
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Writes a mesh into a text file in PLY format.
 Supports ascii and binary formats.
\end_layout

\begin_layout Subsection
STL format 
\end_layout

\begin_layout Standard
The STL format (for "Standard Triangle Language" ) is a file format native to the stereolithography CAD software created by 3D Systems
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
\begin_inset Flex URL
status open

\begin_layout Plain Layout

https://en.wikipedia.org/wiki/STL_(file_format)
\end_layout

\end_inset


\end_layout

\end_inset

.
 It is widely used for 3D printing and computer-aided design.
\end_layout

\begin_layout Standard
Matlab provides support for STL file format through the 
\family typewriter
stlread
\family default
 and 
\family typewriter
stlwrite
\family default
 functions.
 The functions below are simply wrappers to Matlab's native functions,
 that convert the result to the data structure used within MatGeom.
\end_layout

\begin_layout Minisec
readMesh_stl
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
readMesh_stl
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Reads mesh data stored in STL format.
\end_layout

\begin_layout Minisec
writeMesh_stl
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
writeMesh_stl
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Writes a mesh into a text file in STL format.
\end_layout

\begin_layout Subsection
OBJ format
\end_layout

\begin_layout Standard
The OBJ file format is an open file format for representing geometries that was orginally developepd by Wavefront Technologies for its Advanced Visualizer animation package
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
\begin_inset Flex URL
status open

\begin_layout Plain Layout

https://en.wikipedia.org/wiki/Wavefront_.obj_file
\end_layout

\end_inset


\end_layout

\end_inset

.
 The file format has been adopted by other 3D graphics application vendors.
\end_layout

\begin_layout Minisec
readMesh_obj
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout
readMesh_obj
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Read mesh data stored in OBJ format.
\end_layout

\begin_layout Standard
\begin_inset Newpage newpage
\end_inset


\end_layout

\begin_layout Section
Sample meshes
\end_layout

\begin_layout Standard
Several sample meshes are provided within the MatGeom library.
 They are used to illustrate and quickly check some algorithms.
 They are listed in Table
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "tab:Sample-meshes"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Standard
\begin_inset Float table
placement document
alignment document
wide false
sideways false
status open

\begin_layout Plain Layout
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="10" columns="6">
<features tabularvalignment="middle">
<column alignment="center" valignment="top">
<column alignment="center" valignment="top">
<column alignment="center" valignment="top">
<column alignment="center" valignment="top">
<column alignment="center" valignment="top">
<column alignment="left" valignment="top">
<row>
<cell alignment="center" valignment="top" bottomline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\series bold
File name
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $\mathbf{n_{v}}$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $\mathbf{n_{f}}$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
\begin_inset Formula $\mathbf{n_{fv}}$
\end_inset


\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\series bold
File size
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\series bold
Comment
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" bottomline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
apple.ply
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
867
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
1704
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
52 ko
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" bottomline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
bunny_F1k.ply
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
502
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
1000
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
29 ko
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
a simplified version of the 
\begin_inset Quotes eld
\end_inset

stanford bunny
\begin_inset Quotes erd
\end_inset


\begin_inset Newline newline
\end_inset

mesh,
 with 1000 faces
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
bunny_F5k.ply
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
2505
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
5006
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
94 ko
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
a simplified version of the 
\begin_inset Quotes eld
\end_inset

stanford bunny
\begin_inset Quotes erd
\end_inset


\begin_inset Newline newline
\end_inset

mesh,
 with around 5000 faces
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
cube
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
8
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
6
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
4
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
1 ko
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
a simple cube with six square faces
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
dodecahedron.obj
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
20
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
36
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
2 ko
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
The 12 faces have been triangulated
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
dodecahedron.ply
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
20
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
12
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
5
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
1 ko
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
icosahedron.ply
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
12
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
20
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
1 ko
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
mushroom.off
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
226
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
448
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
13 ko
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
teapot.obj
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
530
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
1024
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
53 ko
\end_layout

\end_inset
</cell>
<cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\end_layout

\end_inset
</cell>
</row>
</lyxtabular>

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "tab:Sample-meshes"

\end_inset

Sample meshes.
 
\begin_inset Formula $\mathbf{n_{v}}$
\end_inset

:
 number of vertices,
 
\begin_inset Formula $\mathbf{n_{f}}$
\end_inset

:
 number of faces,
 
\begin_inset Formula $\mathbf{n_{fv}}$
\end_inset

:
 number of vertices (or edges) per face.
\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Chapter
Developer's side
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "chap:Developer-Side"

\end_inset

This chapter gathers information for people interested in contributing new features to the library.
\end_layout

\begin_layout Section
Project organization
\end_layout

\begin_layout Standard
The project is hosted on GitHub
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
\begin_inset Flex URL
status open

\begin_layout Plain Layout

https://github.com/mattools/matGeom
\end_layout

\end_inset


\end_layout

\end_inset

.
 The content under version control comprise the source for the library,
 the tests,
 and most of the documentation (demonstration scripts,
 user manual...).
\end_layout

\begin_layout Standard
The project arborescence is as follow:
\end_layout

\begin_layout Description
checks scripts used to visually check specific parts.
 Mostly outdated.
\end_layout

\begin_layout Description
demos demo scripts used for illustrating specific topics.
\end_layout

\begin_layout Description
docs mostly the source for the user manual (this document).
\end_layout

\begin_layout Description
matGeom the source code for the main part of the library.
\end_layout

\begin_layout Description
tests the scripts used for testing the library,
 see Section
\begin_inset space ~
\end_inset


\begin_inset CommandInset ref
LatexCommand ref
reference "sec:Unit-tests"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Section
Coding conventions
\end_layout

\begin_layout Standard
The general conventions are presented in section 
\begin_inset CommandInset ref
LatexCommand ref
reference "sec:General-conventions"
plural "false"
caps "false"
noprefix "false"
nolink "false"

\end_inset

.
\end_layout

\begin_layout Subsection
File headers
\end_layout

\begin_layout Standard
New functions are expected to contain the following elements:
\end_layout

\begin_layout Itemize
the function line containing function name,
 and input and output arguments
\end_layout

\begin_layout Itemize
the 
\begin_inset Quotes eld
\end_inset

H1
\begin_inset Quotes erd
\end_inset

 header line that summarizes the role of the function
\end_layout

\begin_layout Itemize
several sections describing usage,
 input/output arguments
\end_layout

\begin_layout Itemize
if possible some exame of use
\end_layout

\begin_layout Itemize
a 
\begin_inset Quotes eld
\end_inset

See Also
\begin_inset Quotes erd
\end_inset

 section relating to similar functions
\end_layout

\begin_layout Itemize
some information,
 seperated from the main header,
 related to author and date of creation.
\end_layout

\begin_layout Standard
The 
\begin_inset Quotes eld
\end_inset

tedit
\begin_inset Quotes erd
\end_inset

 contribution by Peter Bodin may be used for the creation of new files
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
\begin_inset Flex URL
status open

\begin_layout Plain Layout

https://fr.mathworks.com/matlabcentral/fileexchange/8532-tedit
\end_layout

\end_inset


\end_layout

\end_inset

.
\end_layout

\begin_layout Subsection
Error messages
\end_layout

\begin_layout Standard
Error messages follow the Matlab convention.
 Error message starts with capital letter and ends with a dot.
 It is recommended to use the 
\begin_inset Quotes eld
\end_inset

MatGeom
\begin_inset Quotes erd
\end_inset

 identifier before the error message:
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

error('MatGeom:theFunction',
 'A problem was encountered.');
\end_layout

\end_inset


\end_layout

\begin_layout Standard
It is also possible to include parameters into error message:
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

error('MatGeom:theFunction',
 'The value %d is invalid.',
 value);
\end_layout

\end_inset


\end_layout

\begin_layout Section
Unit tests
\end_layout

\begin_layout Standard
\begin_inset CommandInset label
LatexCommand label
name "sec:Unit-tests"

\end_inset


\end_layout

\begin_layout Standard
A large number of functions are covered by unit tests,
 using the testing framework provided by Matlab.
 Unit tests are located within the 
\begin_inset Quotes eld
\end_inset

tests
\begin_inset Quotes erd
\end_inset

 directory.
 Each unit test file contains the test(s) associated to a function,
 each test case being implemented as a function.
 Unit test files are named after the functions they are testing (e.g.
 the file 
\begin_inset Quotes eld
\end_inset

test_drawCircle
\begin_inset Quotes erd
\end_inset

 contains the tests for the function 
\begin_inset Quotes eld
\end_inset

drawCircle
\begin_inset Quotes erd
\end_inset

),
 and are organized the same way as the library.
 
\end_layout

\begin_layout Standard
When contributing a new functions,
 providing a set of corresponding unit tests is strongly encouraged.
\end_layout

\begin_layout Subsection
Unit test pattern
\end_layout

\begin_layout Standard
Unit tests usually follow the 
\begin_inset Quotes eld
\end_inset

Arrange-Act-Assert
\begin_inset Quotes erd
\end_inset

 pattern
\begin_inset Foot
status collapsed

\begin_layout Plain Layout
\begin_inset Flex URL
status open

\begin_layout Plain Layout

https://java-design-patterns.com/patterns/arrange-act-assert/
\end_layout

\end_inset


\end_layout

\end_inset

.
 Example:
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

% arrange data for test
\end_layout

\begin_layout Plain Layout

pt1 = [10 10];
\end_layout

\begin_layout Plain Layout

pt2 = [10 20];
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

% 
\begin_inset Quotes eld
\end_inset

act
\begin_inset Quotes erd
\end_inset

:
 perform computation
\end_layout

\begin_layout Plain Layout

dist = distancePoints(pt1,
 pt2);
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

% assert validity of result
\end_layout

\begin_layout Plain Layout

assertEqual(testCase,
 dist,
 10,
 'AbsTol',
 0.01);
\end_layout

\end_inset


\end_layout

\begin_layout Subsection
Unit test of drawing functions
\end_layout

\begin_layout Standard
When testing functions that draw geometries,
 it is necessary to delete the figure displayed during test.
 Example:
\end_layout

\begin_layout Standard
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

circ = [40 30  10];
\end_layout

\begin_layout Plain Layout

hf = figure();
 clf;
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

hc = drawCircle(circ);
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

assertTrue(testCase,
 ishghandle(hc));
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

close(hf);
\end_layout

\end_inset


\end_layout

\begin_layout Section
Utility functions
\end_layout

\begin_layout Standard
Some utility functions have been created for repetitive tasks.
 They are located either within the 
\begin_inset Quotes eld
\end_inset

utils
\begin_inset Quotes erd
\end_inset

 directory of the MatGeom toolbox,
 or within 
\begin_inset Quotes eld
\end_inset

private
\begin_inset Quotes erd
\end_inset

 directories within the modules.
\end_layout

\begin_layout Minisec
isAxisHandle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout

\family roman
\series medium
\shape up
\size normal
\emph off
\nospellcheck off
\bar no
\strikeout off
\xout off
\uuline off
\uwave off
\noun off
\color none
isAxisHandle
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Checks if the input corresponds to a valid axis handle.
 Typical use:
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

% retrieve handle to axis object used for drawing
\end_layout

\begin_layout Plain Layout

if isAxisHandle(varargin{1})
\end_layout

\begin_layout Plain Layout

    hAx = varargin{1};
\end_layout

\begin_layout Plain Layout

    varargin(1) = [];
\end_layout

\begin_layout Plain Layout

else
\end_layout

\begin_layout Plain Layout

    hAx = gca;
\end_layout

\begin_layout Plain Layout

end
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
parseAxisHandle
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout

\family roman
\series medium
\shape up
\size normal
\emph off
\nospellcheck off
\bar no
\strikeout off
\xout off
\uuline off
\uwave off
\noun off
\color none
parseAxisHandle
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Retrieve an handle to an axis handle from a list of input arguments,
 and returns the remaining input arguments as a second output.
 Typical use:
\begin_inset listings
inline false
status open

\begin_layout Plain Layout

[ax,
 varargin] = parseAxisHandle(varargin{:});
\end_layout

\end_inset


\end_layout

\begin_layout Minisec
parseDrawInput
\begin_inset Index idx
range none
pageformat default
status collapsed

\begin_layout Plain Layout

\family roman
\series medium
\shape up
\size normal
\emph off
\nospellcheck off
\bar no
\strikeout off
\xout off
\uuline off
\uwave off
\noun off
\color none
parseDrawInput
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Retrieve the various elements necessary to draw a geometric primitive:
 the axis handle,
 the geometric primitive data,
 and the optional drawing arguments.
\end_layout

\begin_layout Standard
\begin_inset CommandInset index_print
LatexCommand printindex
type "gen"
name "General index"

\end_inset


\begin_inset CommandInset index_print
LatexCommand printindex
type "idx"
name "Index of functions"

\end_inset


\end_layout

\begin_layout Standard
\begin_inset CommandInset bibtex
LatexCommand bibtex
btprint "btPrintCited"
bibfiles "matGeom"
options "bibtotoc,apalike"

\end_inset


\end_layout

\end_body
\end_document
