SlideShare a Scribd company logo
1 of 50
Download to read offline
1Challenge the future
Basic Point Cloud Processing
Estimating Normal Vectors and Curvature Indicators
Ir. Pirouz Nourian
PhD candidate & Instructor, chair of Design Informatics, since 2010
MSc in Architecture 2009
BSc in Control Engineering 2005
Geo1004, Geomatics Master Track
Directed by Dr. ir. Sisi Zlatannova
2Challenge the future
How do we make a computer ‘see’ what we understand from this?
What do you make of this?
What is this all about?
3Challenge the future
Data to Information: LIDAR to LOD2
How do we make sense out of such big data?
Image courtesy of GEOCONNEXION
?
4Challenge the future
SOFTWARE APPLICATIONS
• FME, Safe Software
• LASTools, rapidlasso
• Point Cloud Library (PCL)
• Cloud Compare
• MeshLab
• LP360 QCoherent
A NEW VERSION OF TOIDAR! YES!
http://opentopo.sdsc.eduInformation from:
5Challenge the future
FME, Safe Software
transform, convert, translate, extract, integrate, automated, repeatable
6Challenge the future
LASTools, rapidlasso
filtering, clipping, reprojecting, compression, classification, DSM, DTM, TIN, contours bare-earth
de facto standards for
point cloud data:
.las
.laz
7Challenge the future
LP360, QCoherenet
LIDAR, Classification, Breaklines, Visualization, Extraction, Automatic
8Challenge the future
Point Cloud Library PCL
point clouds, visualization, processing, segmentation, filtering,
feature estimation, registration
Using this library in Rhino?
9Challenge the future
Cloud Compare
Implements PCL and more methods, handy to use for point
cloud processing
Image from software.informer.com
10Challenge the future
MeshLab
Has some surface reconstruction methods, handy to have when
working with point clouds.
Image from https://danieleferdani.wordpress.com/
11Challenge the future
Brainstorm
A sample building extracted from the AHN2 dataset.
?
?
12Challenge the future
Part 1 finished
We will continue with one specific way of dealing with point
clouds and estimating normal vectors and curvatures…
13Challenge the future
An idea!
A sample building extracted from the AHN2 dataset.
14Challenge the future
A Curvature-Based Approach to Point Cloud
Segmentation & Feature Detection
Removing
Outliers
Elevation
Classification
Slope
Classification
Aspect
Classification
Region-Growing
Segmentation
Point Cloud
of a Building
Noise
reduction
Forming
Neighbourhoods:
e.g. KNN or Range
Forming
Covariance
Matrices for
Neighbourhoods
Using PCA, Estimating:
Normal Vectors &
Curvature Indicators
Normal
Vectors
Curvature
Indicators
Eigen
System
Triangulation
Mesh
Surface
15Challenge the future
Different Approaches for Finding Fitting Planes/Edges
1. Using curvature values computed (estimated) by eigenvalues of
covariance matrices, to run a segmentation algorithm based on region
growing.
2. Using Octree Voxels, to detect edge voxels, remove them and create
segments.
3. Using Hough transform on a 2.5D point cloud, converting to the
parameter space and using DBScan clustering method to find
clusters of parameters, each of which correspond to a segment in a
point cloud.
4. And a few more in the literature…
16Challenge the future
Different Approaches for Finding Fitting Planes/Edges
Region growing based on
normals and curvature Segmentation usingOctree voxels Hough transformation
17Challenge the future
Different Approaches for Finding Fitting Planes/Edges:
our experience!
Curvature based region
growing
Voxel based region
growing
Hough transform
Noise management Fair Good Good
Density variation
management
Fair Fair Good
Efficiency Good Good Poor
Ambiguity of vantage
point management
Fair Good Good
Avoiding priori
knowledge
Good Good Poor
Ease of further
processing
Good Poor Poor
18Challenge the future
Neighbourhoods of Points
Fixed Distance Neighbors (FDN) and K-Nearest Neighbors (KNN)
• Rabbani, T., van den Heuvel, F., & Vosselmann, G. (2006). Segmentation of point clouds using smoothness
constraint. International Archives of Photogrammetry, Remote Sensing and Spatial Information
Sciences, 36(5), 248-253.
• Pauling, Frederick, Michael Bosse, and Robert Zlot. "Automatic segmentation of 3d laser point clouds by
ellipsoidal region growing." Australasian Conference on Robotics and Automation. 2009.
The idea is to form neighborhoods based on [squared] distance
These two options are usually provided. Apart from normal vector
estimation KNN can be useful also for removal of outliers.
19Challenge the future
Fitting Planes to Neighbourhoods
The idea is that the underlying surface is a 2-manifold; therefore it
resembles a 2D plane locally
Least Square Plane Fitting Estimation Problem
 Principal Component Analysis Problem
Intuition: Defining plane as the locus of lines that have
direction vectors perpendicular to a normal vector;
considering an origin for the plane in questions, we can
consider the plane as the locus of points A such that A-
O is perpendicular to N.
20Challenge the future
Fitting Planes to Neighbourhoods
The idea is that the underlying surface is a 2-manifold; therefore it
resembles a 2D plane locally, we look at ellipsoids showing local
dispersions
Images courtesy of Olga Sorkine
21Challenge the future
How to estimate normals using PCA
The idea is that the underlying surface is a 2-manifold; therefore it
resembles a 2D plane locally
• Pauly, Mark, Markus Gross, and Leif P. Kobbelt. "Efficient simplification of
point-sampled surfaces." Proceedings of the conference on
Visualization'02. IEEE Computer Society, 2002.
• Hoppe, H., DeRose, T., Duchamp, T., McDonald, J., Stuetzle, W. Surface
reconstruction from unorganized points. SIGGRAPH 92, 1992
• Shaffer, E., Garland, M. Efficient Adaptive Simplification of Massive
Meshes. IEEE Visualization 01, 2001
22Challenge the future
How to estimate normals using PCA
We form a covariance matrix for each neighborhood, showing how
neighbors are dispersed around their average (centroid).
This will be a 3
by 3 symmetric
matrix!
23Challenge the future
How to estimate normals using PCA
We form a covariance matrix for each neighborhood, showing how
neighbors are dispersed around their average (centroid).
This will be a 3
by 3 symmetric
matrix!
Form an Eigen system for this matrix using a
linear algebra library, and the first eigenvector
corresponding to least eigenvalue will be the
normal vector at each neighbourhood.
Explanation follows…
PCL implementation:
http://pointclouds.org/documentation/tutorials/normal_estimation.php
24Challenge the future
How to estimate curvature using PCA
The idea is to use an indication of change along the normal vector
Jolliffe, I. Principle Component Analysis. Springer-Verlag, 1986
25Challenge the future
How to do all this in code?
• We try not to reinvent the wheel; the idea is to use free open
source libraries like Math.NET and Accord.NET
• We are not the first people dealing with such issues, these are
generally matters of data mining and machine learning
• We can find KNN neighbourhoods using
Accord.NET http://accord-framework.net/
• We can find eigenvalues and eigenvectors
using MetaNumerics.dll, MathNet.dll or
Accord.NET
• You will receive example code implementing
MetaNumerics
26Challenge the future
Fitting Planes to Neighbourhoods
How do we minimize the error in fitting a plane to the
mentioned neighbourhood? First we define it…
Images courtesy of Olga Sorkine
27Challenge the future
An explanation after Olga Sorkine:
• Input points:
• Centroid:
• Vectors from the centroid:
m
28Challenge the future
Continued…
mm minimizes SSD and it can
be shown that m is the
centroid C
We can rewrite the problem as:
29Challenge the future
Continued…
m
m minimizes SSD, formally it is the
“arg min” of the following function
(to be minimized), i.e. the argument
that makes it reach its minimum. and
it can be shown that m is the
centroid C
Solving this turns out to be equal to
solving an Eigen system for the
covariance matrix; you can see how…
30Challenge the future
Long story short…
We find eigenvalues and eigenvectors of the covariance matrices…
31Challenge the future
Long story short…
We find eigenvalues and eigenvectors of the covariance matrices…
What was this all about? Segmenting the point cloud taking into
account [underlying] surface variations, in search of smooth patches,
made disjoint by edges (where we find high curvature/variation).
Therefore we can use the above estimated vectors and values for
such a segmentation.
32Challenge the future
Explanation from lecture notes of Olga Sorkine…
33Challenge the future
Continued from lecture notes of Olga Sorkine…
34Challenge the future
Continued from lecture notes of Olga Sorkine…
This S is our covariance
matrix, remember?
35Challenge the future
•Constrained minimization – Lagrange multipliers
Continued from lecture notes of Olga Sorkine…
Given this equality in
differentiation of vector
valued functions
36Challenge the future
•Constrained minimization – Lagrange multipliers
Continued from lecture notes of Olga Sorkine…
maximize f(x, y) subject to g(x, y) = c.
Lagrangian:
The prblem is transformed to finding a ‘’staionary
point for the Langrangian at which the partial
derivatives of Lagrangian function are zero.
37Challenge the future
•Constrained minimization – Lagrange multipliers
Continued from lecture notes of Olga Sorkine…
This one means that the
normal vector is
normalized, meaning its
length is equal to 1; why,
because the dot product
of a vector by itself gives
the squared length
38Challenge the future
How to form covariance matrices in code?
VB.NET (confirm and debug for yourself)
If(Pts.Count > 3) Then
Dim CovMatrices As New list(Of Meta.Numerics.Matrices.SymmetricMatrix)
For j As Integer=0 To Pts.Count - 1
Dim CovM As New Meta.Numerics.Matrices.SymmetricMatrix(3)
Dim Neighbors As List(Of Integer) = DirectCast(Neigh(j), List(Of Integer))
Dim Centroid As New Point3d
Dim NPts As New List(Of Point3d)
For Each neighbor As Integer In Neighbors
Centroid = Centroid + Pts(neighbor)
NPts.Add(Pts(neighbor))
Next
Centroid = Centroid / Neighbors.Count
Dim CiCBar As New RectangularMatrix(3, Neighbors.Count)
For k As Integer=0 To Neighbors.count - 1
Dim Diff As point3d = Pts(Neighbors(k)) - Centroid
CiCBar(0, k) = Diff.X
CiCBar(1, k) = Diff.y
CiCBar(2, k) = Diff.z
Next
CovM = CiCBar.MultiplySelfByTranspose()
CovM = (1 / (Neighbors.count - 1)) * CovM
CovMatrices.Add(CovM)
Next
A = CovMatrices(0).ToArray()
C = CovMatrices
End If
39Challenge the future
How to form covariance matrices in code?
C#.NET (confirm and debug for yourself)
if ((Pts.Count > 3)) {
List<Meta.Numerics.Matrices.SymmetricMatrix> CovMatrices = new List<Meta.Numerics.Matrices.SymmetricMatrix>();
for (int j = 0; j <= Pts.Count - 1; j++) {
Meta.Numerics.Matrices.SymmetricMatrix CovM = new Meta.Numerics.Matrices.SymmetricMatrix(3);
List<int> Neighbors = (List<int>)Neigh(j);
Point3d Centroid = new Point3d();
List<Point3d> NPts = new List<Point3d>();
foreach (int neighbor in Neighbors) {
Centroid = Centroid + Pts(neighbor);
NPts.Add(Pts(neighbor));
}
Centroid = Centroid / Neighbors.Count;
RectangularMatrix CiCBar = new RectangularMatrix(3, Neighbors.Count);
for (int k = 0; k <= Neighbors.count - 1; k++) {
point3d Diff = Pts(Neighbors(k)) - Centroid;
CiCBar(0, k) = Diff.X;
CiCBar(1, k) = Diff.y;
CiCBar(2, k) = Diff.z;
}
CovM = CiCBar.MultiplySelfByTranspose();
CovM = (1 / (Neighbors.count - 1)) * CovM;
CovMatrices.Add(CovM);
}
A = CovMatrices(0).ToArray();
C = CovMatrices;
}
40Challenge the future
Part 2 finished
Some hints on previous assignment follow…
41Challenge the future
Grid Surface Reconstruction
Pseudo-Code
Define a new Mesh with a list of Vertices and a list of Faces
Mesh.Vertices=Points
For j as Integer=0 to V-2//choose only bottom-left corners as pivot points
For i As Integer=0 To U - 2
define n0,n1,n2,n3 As Integer
n0 = j * U + I //bottom-left
n1 = n0 + 1 //bottom-right
n2 = n0 + U //top-right
n3 = n1 + U //top-left
Define face As new MeshFace(n0, n1, n3, n2)
Mesh.Faces.AddFace(face)
Next
Next
42Challenge the future
Grid Surface Reconstruction
VB.NET
Dim M As New Mesh
M.Vertices.AddVertices(P)
If Not C Is Nothing Then
M.VertexColors.AppendColors(C.toArray)
For j As Integer=0 To V - 2
For i As Integer=0 To U - 2
Dim n0,n1,n2,n3 As Integer
n0 = j * U + i
n1 = n0 + 1
n2 = n0 + U
n3 = n1 + U
Dim face As MeshFace = New MeshFace(n0, n1, n3, n2)
M.Faces.AddFace(face)
Next
Next
with two nested loops
43Challenge the future
Grid Surface Reconstruction
VB.NET
Dim M As New Mesh
M.Vertices.AddVertices(P)
If Not C Is Nothing Then
M.VertexColors.AppendColors(C.toArray)
For i As Integer=0 To U * (V - 1) - 1
If (i Mod u) < u - 1 Then
Dim n0,n1,n2,n3 As Integer
n0 = i
n1 = n0 + 1
n2 = n0 + U
n3 = n1 + U
Dim face As MeshFace = New MeshFace(n0, n1, n3, n2)
M.Faces.AddFace(face)
End If
Next
with one loop
44Challenge the future
Grid Surface Reconstruction
C#.NET
Mesh M = new Mesh();
M.Vertices.AddVertices(P);
if ((C != null))
M.VertexColors.AppendColors(C.toArray);
for (int i = 0; i <= U * (V - 1) - 1; i++) {
if ((i % u) < u - 1) {
int n0 = 0;
int n1 = 0;
int n2 = 0;
int n3 = 0;
n0 = i;
n1 = n0 + 1;
n2 = n0 + U;
n3 = n1 + U;
MeshFace face = new MeshFace(n0,
n1, n3, n2);
M.Faces.AddFace(face);
}
}
with one loop
45Challenge the future
Simple Estimation of Normal
Vectors Pseudo-Code
Form an empty list of normal vectors
Define deviation as a double
For each point as Point3d in the point cloud
find neighbors
fit a plane to neighbors
Get the normal of this plane and put it out as the normal of the point
form a vector from the vantage point VP to point=VP-point and call it dir
if this normal.dir>0 then
Add the normal to the list of normals
Else
Add –normal to the list of normals
End
Next
46Challenge the future
Estimation Normal Vectors
C#.NET
List<Vector3d> Normals = new List<Vector3d>();
Point3dList PCList = new Point3dList();
PCList.AddRange(x);
double Dev = MD;
foreach (Point3d point in PCList) {
dynamic Neighbors = PCList.FindAll(V => V.DistanceTo(point) < D);
plane NP = default(Plane);
Plane.FitPlaneToPoints(Neighbors, NP, Dev);
if (NP.Normal * (VP - point) > 0) {
Normals.Add(NP.Normal);
} else {
Normals.Add(-NP.Normal);
}
}
A = Normals;
B = PCList.FindAll(VT => VT.DistanceTo(x(654)) < D);
47Challenge the future
Estimation Normal Vectors
VB.NET
Dim Normals As New list(Of Vector3d)
Dim PCList As New point3dlist
PClist.AddRange(x)
Dim Dev As Double = MD
For Each point As point3d In PClist
Dim Neighbors = PClist.FindAll(Function(V) V.distanceto(point) < D)
Dim NP As plane
Plane.FitPlaneToPoints(Neighbors, NP, Dev)
If NP.Normal * (VP - point) > 0 Then
Normals.Add(NP.Normal)
Else
Normals.Add(-NP.Normal)
End if
Next
A = Normals
B = PClist.FindAll(Function(VT) VT.DistanceTo(x(654)) < D)
48Challenge the future
Basics of Scripting in Rhino + GH
• VB.NET (Sub[routine], Function, ByVal, ByRef)
• C#.NET (Void, [Functions], [val],ref)
• Python (defs)
Basic concepts of systems and modules, Inputs & Outputs
Private Sub RunScript(ByVal x As Object, ByVal y As Object, ByRef A As
Object)
End Sub
'<Custom additional code>
'</Custom additional code>
Function plus(A As Integer, B As Integer) As
Integer
Return A + B
End Function
private void RunScript(object x, object y, ref object A)
{
}
// <Custom additional code>
// </Custom additional code>
public int plus(int a, int b)
{
return a + b;
}
def plus(a,b):
return a+b
Nothing visible.
49Challenge the future
Basics of Scripting in Rhino + GH
• Rhinocommon
• Rhinoscript
• Grasshopper Kernel
Rhinocommon
Library of
Geometry
Operations
VB.NET. C#.NET &
Python
Grasshopper Kernel
Library of Some
Special Geometry
Operations
VB.NET. C#.NET &
Python
Rhionscript (with [Iron]Python)
Operations as in Rhino Command Line
Python
http://4.rhino3d.com/5/rhinocommon/Rhinocommon SDK:
Grasshopper SDK: [Rhino]Command: GrasshopperGetSDKDocumentation
Rhinoscript Syntax SDK: [GH Python]Help: Rhinoscript syntax help
50Challenge the future
Questions? p.nourian@tudelft.nl
• I will give you the tools we have developed so far as open
source;
• You will make them better using the following libraries;
• Using either Math.NET or MetaNumerics is a must;
• Using Accord.NET is a big plus!
• If you are using Python, use similar libraries such as SciPy
• If you want to do something else let us discuss it now!

More Related Content

What's hot

What's hot (20)

Visual-SLAM技術を利用した 果樹園の3次元圃場地図の作成
Visual-SLAM技術を利用した果樹園の3次元圃場地図の作成Visual-SLAM技術を利用した果樹園の3次元圃場地図の作成
Visual-SLAM技術を利用した 果樹園の3次元圃場地図の作成
 
VoxFormer: Sparse Voxel Transformer for Camera-based 3D Semantic Scene Comple...
VoxFormer: Sparse Voxel Transformer for Camera-based 3D Semantic Scene Comple...VoxFormer: Sparse Voxel Transformer for Camera-based 3D Semantic Scene Comple...
VoxFormer: Sparse Voxel Transformer for Camera-based 3D Semantic Scene Comple...
 
SSII2019企画: 画像および LiDAR を用いた自動走行に関する動向
SSII2019企画: 画像および LiDAR を用いた自動走行に関する動向SSII2019企画: 画像および LiDAR を用いた自動走行に関する動向
SSII2019企画: 画像および LiDAR を用いた自動走行に関する動向
 
Brochure TurtleBot3(A4)
Brochure TurtleBot3(A4)Brochure TurtleBot3(A4)
Brochure TurtleBot3(A4)
 
SSII2019企画: 点群深層学習の研究動向
SSII2019企画: 点群深層学習の研究動向SSII2019企画: 点群深層学習の研究動向
SSII2019企画: 点群深層学習の研究動向
 
再生可能エネルギーの普及動向と課題
再生可能エネルギーの普及動向と課題再生可能エネルギーの普及動向と課題
再生可能エネルギーの普及動向と課題
 
コンピュータビジョンの最新ソフトウェア開発環境 SSII2015 チュートリアル hayashi
コンピュータビジョンの最新ソフトウェア開発環境 SSII2015 チュートリアル hayashiコンピュータビジョンの最新ソフトウェア開発環境 SSII2015 チュートリアル hayashi
コンピュータビジョンの最新ソフトウェア開発環境 SSII2015 チュートリアル hayashi
 
CVPR2019読み会 "A Theory of Fermat Paths for Non-Line-of-Sight Shape Reconstruc...
CVPR2019読み会 "A Theory of Fermat Paths  for Non-Line-of-Sight Shape Reconstruc...CVPR2019読み会 "A Theory of Fermat Paths  for Non-Line-of-Sight Shape Reconstruc...
CVPR2019読み会 "A Theory of Fermat Paths for Non-Line-of-Sight Shape Reconstruc...
 
ROS を用いた自律移動ロボットのシステム構築
ROS を用いた自律移動ロボットのシステム構築ROS を用いた自律移動ロボットのシステム構築
ROS を用いた自律移動ロボットのシステム構築
 
第126回 ロボット工学セミナー 三次元点群と深層学習
第126回 ロボット工学セミナー 三次元点群と深層学習第126回 ロボット工学セミナー 三次元点群と深層学習
第126回 ロボット工学セミナー 三次元点群と深層学習
 
WSL2+docker+JupyterとVS Codeリモート環境の構築
WSL2+docker+JupyterとVS Codeリモート環境の構築WSL2+docker+JupyterとVS Codeリモート環境の構築
WSL2+docker+JupyterとVS Codeリモート環境の構築
 
-SSIIの技術マップ- 過去•現在, そして未来 [領域]認識
-SSIIの技術マップ- 過去•現在, そして未来 [領域]認識-SSIIの技術マップ- 過去•現在, そして未来 [領域]認識
-SSIIの技術マップ- 過去•現在, そして未来 [領域]認識
 
KiCadで雑に基板を作る チュートリアル
KiCadで雑に基板を作る チュートリアルKiCadで雑に基板を作る チュートリアル
KiCadで雑に基板を作る チュートリアル
 
SLAM入門 第2章 SLAMの基礎
SLAM入門 第2章 SLAMの基礎SLAM入門 第2章 SLAMの基礎
SLAM入門 第2章 SLAMの基礎
 
20180424 orb slam
20180424 orb slam20180424 orb slam
20180424 orb slam
 
3万円台でマイ電子基準点を設置してみよう
3万円台でマイ電子基準点を設置してみよう3万円台でマイ電子基準点を設置してみよう
3万円台でマイ電子基準点を設置してみよう
 
基板から回路図を起こしてみよう
基板から回路図を起こしてみよう基板から回路図を起こしてみよう
基板から回路図を起こしてみよう
 
Visual slam
Visual slamVisual slam
Visual slam
 
Global Illumination
Global IlluminationGlobal Illumination
Global Illumination
 
ロボティクスにおける SLAM 手法と実用化例
ロボティクスにおける SLAM 手法と実用化例ロボティクスにおける SLAM 手法と実用化例
ロボティクスにおける SLAM 手法と実用化例
 

Viewers also liked

Viewers also liked (7)

Point Cloud Segmentation for 3D Reconstruction
Point Cloud Segmentation for 3D ReconstructionPoint Cloud Segmentation for 3D Reconstruction
Point Cloud Segmentation for 3D Reconstruction
 
Tudelft stramien 16_9_on_optimization
Tudelft stramien 16_9_on_optimizationTudelft stramien 16_9_on_optimization
Tudelft stramien 16_9_on_optimization
 
Polygon Mesh Representation
Polygon Mesh RepresentationPolygon Mesh Representation
Polygon Mesh Representation
 
Preliminaries of Analytic Geometry and Linear Algebra 3D modelling
Preliminaries of Analytic Geometry and Linear Algebra 3D modellingPreliminaries of Analytic Geometry and Linear Algebra 3D modelling
Preliminaries of Analytic Geometry and Linear Algebra 3D modelling
 
On NURBS Geometry Representation in 3D modelling
On NURBS Geometry Representation in 3D modellingOn NURBS Geometry Representation in 3D modelling
On NURBS Geometry Representation in 3D modelling
 
Intro computational design_mega2016_1_with_recommendedplugins
Intro computational design_mega2016_1_with_recommendedpluginsIntro computational design_mega2016_1_with_recommendedplugins
Intro computational design_mega2016_1_with_recommendedplugins
 
Surface reconstruction from point clouds using optimal transportation
Surface reconstruction from point clouds using optimal transportationSurface reconstruction from point clouds using optimal transportation
Surface reconstruction from point clouds using optimal transportation
 

Similar to Point Cloud Processing: Estimating Normal Vectors and Curvature Indicators using Eigenvectors

Machine Learning Project
Machine Learning ProjectMachine Learning Project
Machine Learning Project
Adeyemi Fowe
 

Similar to Point Cloud Processing: Estimating Normal Vectors and Curvature Indicators using Eigenvectors (20)

Machine Learning Project
Machine Learning ProjectMachine Learning Project
Machine Learning Project
 
Unsupervised Deep Learning (D2L1 Insight@DCU Machine Learning Workshop 2017)
Unsupervised Deep Learning (D2L1 Insight@DCU Machine Learning Workshop 2017)Unsupervised Deep Learning (D2L1 Insight@DCU Machine Learning Workshop 2017)
Unsupervised Deep Learning (D2L1 Insight@DCU Machine Learning Workshop 2017)
 
Object Detection with Transformers
Object Detection with TransformersObject Detection with Transformers
Object Detection with Transformers
 
Report
ReportReport
Report
 
Mirko Lucchese - Deep Image Processing
Mirko Lucchese - Deep Image ProcessingMirko Lucchese - Deep Image Processing
Mirko Lucchese - Deep Image Processing
 
lecture_16.pptx
lecture_16.pptxlecture_16.pptx
lecture_16.pptx
 
Build Your Own 3D Scanner: Surface Reconstruction
Build Your Own 3D Scanner: Surface ReconstructionBuild Your Own 3D Scanner: Surface Reconstruction
Build Your Own 3D Scanner: Surface Reconstruction
 
Two marks with answers ME6501 CAD
Two marks with answers ME6501 CADTwo marks with answers ME6501 CAD
Two marks with answers ME6501 CAD
 
Moving object detection in complex scene
Moving object detection in complex sceneMoving object detection in complex scene
Moving object detection in complex scene
 
Visual geometry with deep learning
Visual geometry with deep learningVisual geometry with deep learning
Visual geometry with deep learning
 
Shor's discrete logarithm quantum algorithm for elliptic curves
 Shor's discrete logarithm quantum algorithm for elliptic curves Shor's discrete logarithm quantum algorithm for elliptic curves
Shor's discrete logarithm quantum algorithm for elliptic curves
 
Deep learning for molecules, introduction to chainer chemistry
Deep learning for molecules, introduction to chainer chemistryDeep learning for molecules, introduction to chainer chemistry
Deep learning for molecules, introduction to chainer chemistry
 
Manifold Blurring Mean Shift algorithms for manifold denoising, report, 2012
Manifold Blurring Mean Shift algorithms for manifold denoising, report, 2012Manifold Blurring Mean Shift algorithms for manifold denoising, report, 2012
Manifold Blurring Mean Shift algorithms for manifold denoising, report, 2012
 
Transformer in Vision
Transformer in VisionTransformer in Vision
Transformer in Vision
 
Artificial Intelligence, Machine Learning and Deep Learning
Artificial Intelligence, Machine Learning and Deep LearningArtificial Intelligence, Machine Learning and Deep Learning
Artificial Intelligence, Machine Learning and Deep Learning
 
Introduction to 3D Computer Vision and Differentiable Rendering
Introduction to 3D Computer Vision and Differentiable RenderingIntroduction to 3D Computer Vision and Differentiable Rendering
Introduction to 3D Computer Vision and Differentiable Rendering
 
Fisheye Omnidirectional View in Autonomous Driving
Fisheye Omnidirectional View in Autonomous DrivingFisheye Omnidirectional View in Autonomous Driving
Fisheye Omnidirectional View in Autonomous Driving
 
Fa18_P2.pptx
Fa18_P2.pptxFa18_P2.pptx
Fa18_P2.pptx
 
15_NEW-2020-ATTENTION-ENC-DEC-TRANSFORMERS-Lect15.pptx
15_NEW-2020-ATTENTION-ENC-DEC-TRANSFORMERS-Lect15.pptx15_NEW-2020-ATTENTION-ENC-DEC-TRANSFORMERS-Lect15.pptx
15_NEW-2020-ATTENTION-ENC-DEC-TRANSFORMERS-Lect15.pptx
 
A brief introduction to recent segmentation methods
A brief introduction to recent segmentation methodsA brief introduction to recent segmentation methods
A brief introduction to recent segmentation methods
 

More from Pirouz Nourian

More from Pirouz Nourian (8)

Geo1004 lecture 1_topology&amp;topological_datamodels_final
Geo1004 lecture 1_topology&amp;topological_datamodels_finalGeo1004 lecture 1_topology&amp;topological_datamodels_final
Geo1004 lecture 1_topology&amp;topological_datamodels_final
 
Ar1 twf030 lecture3.1: Design Optimization
Ar1 twf030 lecture3.1: Design OptimizationAr1 twf030 lecture3.1: Design Optimization
Ar1 twf030 lecture3.1: Design Optimization
 
Ar1 twf030 lecture2.2
Ar1 twf030 lecture2.2Ar1 twf030 lecture2.2
Ar1 twf030 lecture2.2
 
Ar1 twf030 lecture1.1
Ar1 twf030 lecture1.1Ar1 twf030 lecture1.1
Ar1 twf030 lecture1.1
 
Ar1 twf030 lecture1.2
Ar1 twf030 lecture1.2Ar1 twf030 lecture1.2
Ar1 twf030 lecture1.2
 
Ar1 twf030 lecture2.1: Geometry and Topology in Computational Design
Ar1 twf030 lecture2.1: Geometry and Topology in Computational DesignAr1 twf030 lecture2.1: Geometry and Topology in Computational Design
Ar1 twf030 lecture2.1: Geometry and Topology in Computational Design
 
Mesh final pzn_geo1004_2015_f3_2017
Mesh final pzn_geo1004_2015_f3_2017Mesh final pzn_geo1004_2015_f3_2017
Mesh final pzn_geo1004_2015_f3_2017
 
Syntactic space syntax4generativedesign
Syntactic space syntax4generativedesignSyntactic space syntax4generativedesign
Syntactic space syntax4generativedesign
 

Recently uploaded

一比一原版(UofT毕业证)多伦多大学毕业证成绩单
一比一原版(UofT毕业证)多伦多大学毕业证成绩单一比一原版(UofT毕业证)多伦多大学毕业证成绩单
一比一原版(UofT毕业证)多伦多大学毕业证成绩单
tuuww
 
DR PROF ING GURUDUTT SAHNI WIKIPEDIA.pdf
DR PROF ING GURUDUTT SAHNI WIKIPEDIA.pdfDR PROF ING GURUDUTT SAHNI WIKIPEDIA.pdf
DR PROF ING GURUDUTT SAHNI WIKIPEDIA.pdf
DrGurudutt
 
School management system project report.pdf
School management system project report.pdfSchool management system project report.pdf
School management system project report.pdf
Kamal Acharya
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
Kamal Acharya
 

Recently uploaded (20)

一比一原版(UofT毕业证)多伦多大学毕业证成绩单
一比一原版(UofT毕业证)多伦多大学毕业证成绩单一比一原版(UofT毕业证)多伦多大学毕业证成绩单
一比一原版(UofT毕业证)多伦多大学毕业证成绩单
 
Supermarket billing system project report..pdf
Supermarket billing system project report..pdfSupermarket billing system project report..pdf
Supermarket billing system project report..pdf
 
DR PROF ING GURUDUTT SAHNI WIKIPEDIA.pdf
DR PROF ING GURUDUTT SAHNI WIKIPEDIA.pdfDR PROF ING GURUDUTT SAHNI WIKIPEDIA.pdf
DR PROF ING GURUDUTT SAHNI WIKIPEDIA.pdf
 
RM&IPR M4.pdfResearch Methodolgy & Intellectual Property Rights Series 4
RM&IPR M4.pdfResearch Methodolgy & Intellectual Property Rights Series 4RM&IPR M4.pdfResearch Methodolgy & Intellectual Property Rights Series 4
RM&IPR M4.pdfResearch Methodolgy & Intellectual Property Rights Series 4
 
School management system project report.pdf
School management system project report.pdfSchool management system project report.pdf
School management system project report.pdf
 
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamKIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
 
Furniture showroom management system project.pdf
Furniture showroom management system project.pdfFurniture showroom management system project.pdf
Furniture showroom management system project.pdf
 
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGBRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
 
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...
NO1 Pandit Black Magic Removal in Uk kala jadu Specialist kala jadu for Love ...
 
Peek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdfPeek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdf
 
Natalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in KrakówNatalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in Kraków
 
Online book store management system project.pdf
Online book store management system project.pdfOnline book store management system project.pdf
Online book store management system project.pdf
 
Top 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering ScientistTop 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering Scientist
 
Arduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectArduino based vehicle speed tracker project
Arduino based vehicle speed tracker project
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdf
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
 
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringKIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
 
Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2
 
ONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdf
ONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdfONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdf
ONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdf
 
1. Henrich Triangle Safety and Fire Presentation
1. Henrich Triangle Safety and Fire Presentation1. Henrich Triangle Safety and Fire Presentation
1. Henrich Triangle Safety and Fire Presentation
 

Point Cloud Processing: Estimating Normal Vectors and Curvature Indicators using Eigenvectors

  • 1. 1Challenge the future Basic Point Cloud Processing Estimating Normal Vectors and Curvature Indicators Ir. Pirouz Nourian PhD candidate & Instructor, chair of Design Informatics, since 2010 MSc in Architecture 2009 BSc in Control Engineering 2005 Geo1004, Geomatics Master Track Directed by Dr. ir. Sisi Zlatannova
  • 2. 2Challenge the future How do we make a computer ‘see’ what we understand from this? What do you make of this? What is this all about?
  • 3. 3Challenge the future Data to Information: LIDAR to LOD2 How do we make sense out of such big data? Image courtesy of GEOCONNEXION ?
  • 4. 4Challenge the future SOFTWARE APPLICATIONS • FME, Safe Software • LASTools, rapidlasso • Point Cloud Library (PCL) • Cloud Compare • MeshLab • LP360 QCoherent A NEW VERSION OF TOIDAR! YES! http://opentopo.sdsc.eduInformation from:
  • 5. 5Challenge the future FME, Safe Software transform, convert, translate, extract, integrate, automated, repeatable
  • 6. 6Challenge the future LASTools, rapidlasso filtering, clipping, reprojecting, compression, classification, DSM, DTM, TIN, contours bare-earth de facto standards for point cloud data: .las .laz
  • 7. 7Challenge the future LP360, QCoherenet LIDAR, Classification, Breaklines, Visualization, Extraction, Automatic
  • 8. 8Challenge the future Point Cloud Library PCL point clouds, visualization, processing, segmentation, filtering, feature estimation, registration Using this library in Rhino?
  • 9. 9Challenge the future Cloud Compare Implements PCL and more methods, handy to use for point cloud processing Image from software.informer.com
  • 10. 10Challenge the future MeshLab Has some surface reconstruction methods, handy to have when working with point clouds. Image from https://danieleferdani.wordpress.com/
  • 11. 11Challenge the future Brainstorm A sample building extracted from the AHN2 dataset. ? ?
  • 12. 12Challenge the future Part 1 finished We will continue with one specific way of dealing with point clouds and estimating normal vectors and curvatures…
  • 13. 13Challenge the future An idea! A sample building extracted from the AHN2 dataset.
  • 14. 14Challenge the future A Curvature-Based Approach to Point Cloud Segmentation & Feature Detection Removing Outliers Elevation Classification Slope Classification Aspect Classification Region-Growing Segmentation Point Cloud of a Building Noise reduction Forming Neighbourhoods: e.g. KNN or Range Forming Covariance Matrices for Neighbourhoods Using PCA, Estimating: Normal Vectors & Curvature Indicators Normal Vectors Curvature Indicators Eigen System Triangulation Mesh Surface
  • 15. 15Challenge the future Different Approaches for Finding Fitting Planes/Edges 1. Using curvature values computed (estimated) by eigenvalues of covariance matrices, to run a segmentation algorithm based on region growing. 2. Using Octree Voxels, to detect edge voxels, remove them and create segments. 3. Using Hough transform on a 2.5D point cloud, converting to the parameter space and using DBScan clustering method to find clusters of parameters, each of which correspond to a segment in a point cloud. 4. And a few more in the literature…
  • 16. 16Challenge the future Different Approaches for Finding Fitting Planes/Edges Region growing based on normals and curvature Segmentation usingOctree voxels Hough transformation
  • 17. 17Challenge the future Different Approaches for Finding Fitting Planes/Edges: our experience! Curvature based region growing Voxel based region growing Hough transform Noise management Fair Good Good Density variation management Fair Fair Good Efficiency Good Good Poor Ambiguity of vantage point management Fair Good Good Avoiding priori knowledge Good Good Poor Ease of further processing Good Poor Poor
  • 18. 18Challenge the future Neighbourhoods of Points Fixed Distance Neighbors (FDN) and K-Nearest Neighbors (KNN) • Rabbani, T., van den Heuvel, F., & Vosselmann, G. (2006). Segmentation of point clouds using smoothness constraint. International Archives of Photogrammetry, Remote Sensing and Spatial Information Sciences, 36(5), 248-253. • Pauling, Frederick, Michael Bosse, and Robert Zlot. "Automatic segmentation of 3d laser point clouds by ellipsoidal region growing." Australasian Conference on Robotics and Automation. 2009. The idea is to form neighborhoods based on [squared] distance These two options are usually provided. Apart from normal vector estimation KNN can be useful also for removal of outliers.
  • 19. 19Challenge the future Fitting Planes to Neighbourhoods The idea is that the underlying surface is a 2-manifold; therefore it resembles a 2D plane locally Least Square Plane Fitting Estimation Problem  Principal Component Analysis Problem Intuition: Defining plane as the locus of lines that have direction vectors perpendicular to a normal vector; considering an origin for the plane in questions, we can consider the plane as the locus of points A such that A- O is perpendicular to N.
  • 20. 20Challenge the future Fitting Planes to Neighbourhoods The idea is that the underlying surface is a 2-manifold; therefore it resembles a 2D plane locally, we look at ellipsoids showing local dispersions Images courtesy of Olga Sorkine
  • 21. 21Challenge the future How to estimate normals using PCA The idea is that the underlying surface is a 2-manifold; therefore it resembles a 2D plane locally • Pauly, Mark, Markus Gross, and Leif P. Kobbelt. "Efficient simplification of point-sampled surfaces." Proceedings of the conference on Visualization'02. IEEE Computer Society, 2002. • Hoppe, H., DeRose, T., Duchamp, T., McDonald, J., Stuetzle, W. Surface reconstruction from unorganized points. SIGGRAPH 92, 1992 • Shaffer, E., Garland, M. Efficient Adaptive Simplification of Massive Meshes. IEEE Visualization 01, 2001
  • 22. 22Challenge the future How to estimate normals using PCA We form a covariance matrix for each neighborhood, showing how neighbors are dispersed around their average (centroid). This will be a 3 by 3 symmetric matrix!
  • 23. 23Challenge the future How to estimate normals using PCA We form a covariance matrix for each neighborhood, showing how neighbors are dispersed around their average (centroid). This will be a 3 by 3 symmetric matrix! Form an Eigen system for this matrix using a linear algebra library, and the first eigenvector corresponding to least eigenvalue will be the normal vector at each neighbourhood. Explanation follows… PCL implementation: http://pointclouds.org/documentation/tutorials/normal_estimation.php
  • 24. 24Challenge the future How to estimate curvature using PCA The idea is to use an indication of change along the normal vector Jolliffe, I. Principle Component Analysis. Springer-Verlag, 1986
  • 25. 25Challenge the future How to do all this in code? • We try not to reinvent the wheel; the idea is to use free open source libraries like Math.NET and Accord.NET • We are not the first people dealing with such issues, these are generally matters of data mining and machine learning • We can find KNN neighbourhoods using Accord.NET http://accord-framework.net/ • We can find eigenvalues and eigenvectors using MetaNumerics.dll, MathNet.dll or Accord.NET • You will receive example code implementing MetaNumerics
  • 26. 26Challenge the future Fitting Planes to Neighbourhoods How do we minimize the error in fitting a plane to the mentioned neighbourhood? First we define it… Images courtesy of Olga Sorkine
  • 27. 27Challenge the future An explanation after Olga Sorkine: • Input points: • Centroid: • Vectors from the centroid: m
  • 28. 28Challenge the future Continued… mm minimizes SSD and it can be shown that m is the centroid C We can rewrite the problem as:
  • 29. 29Challenge the future Continued… m m minimizes SSD, formally it is the “arg min” of the following function (to be minimized), i.e. the argument that makes it reach its minimum. and it can be shown that m is the centroid C Solving this turns out to be equal to solving an Eigen system for the covariance matrix; you can see how…
  • 30. 30Challenge the future Long story short… We find eigenvalues and eigenvectors of the covariance matrices…
  • 31. 31Challenge the future Long story short… We find eigenvalues and eigenvectors of the covariance matrices… What was this all about? Segmenting the point cloud taking into account [underlying] surface variations, in search of smooth patches, made disjoint by edges (where we find high curvature/variation). Therefore we can use the above estimated vectors and values for such a segmentation.
  • 32. 32Challenge the future Explanation from lecture notes of Olga Sorkine…
  • 33. 33Challenge the future Continued from lecture notes of Olga Sorkine…
  • 34. 34Challenge the future Continued from lecture notes of Olga Sorkine… This S is our covariance matrix, remember?
  • 35. 35Challenge the future •Constrained minimization – Lagrange multipliers Continued from lecture notes of Olga Sorkine… Given this equality in differentiation of vector valued functions
  • 36. 36Challenge the future •Constrained minimization – Lagrange multipliers Continued from lecture notes of Olga Sorkine… maximize f(x, y) subject to g(x, y) = c. Lagrangian: The prblem is transformed to finding a ‘’staionary point for the Langrangian at which the partial derivatives of Lagrangian function are zero.
  • 37. 37Challenge the future •Constrained minimization – Lagrange multipliers Continued from lecture notes of Olga Sorkine… This one means that the normal vector is normalized, meaning its length is equal to 1; why, because the dot product of a vector by itself gives the squared length
  • 38. 38Challenge the future How to form covariance matrices in code? VB.NET (confirm and debug for yourself) If(Pts.Count > 3) Then Dim CovMatrices As New list(Of Meta.Numerics.Matrices.SymmetricMatrix) For j As Integer=0 To Pts.Count - 1 Dim CovM As New Meta.Numerics.Matrices.SymmetricMatrix(3) Dim Neighbors As List(Of Integer) = DirectCast(Neigh(j), List(Of Integer)) Dim Centroid As New Point3d Dim NPts As New List(Of Point3d) For Each neighbor As Integer In Neighbors Centroid = Centroid + Pts(neighbor) NPts.Add(Pts(neighbor)) Next Centroid = Centroid / Neighbors.Count Dim CiCBar As New RectangularMatrix(3, Neighbors.Count) For k As Integer=0 To Neighbors.count - 1 Dim Diff As point3d = Pts(Neighbors(k)) - Centroid CiCBar(0, k) = Diff.X CiCBar(1, k) = Diff.y CiCBar(2, k) = Diff.z Next CovM = CiCBar.MultiplySelfByTranspose() CovM = (1 / (Neighbors.count - 1)) * CovM CovMatrices.Add(CovM) Next A = CovMatrices(0).ToArray() C = CovMatrices End If
  • 39. 39Challenge the future How to form covariance matrices in code? C#.NET (confirm and debug for yourself) if ((Pts.Count > 3)) { List<Meta.Numerics.Matrices.SymmetricMatrix> CovMatrices = new List<Meta.Numerics.Matrices.SymmetricMatrix>(); for (int j = 0; j <= Pts.Count - 1; j++) { Meta.Numerics.Matrices.SymmetricMatrix CovM = new Meta.Numerics.Matrices.SymmetricMatrix(3); List<int> Neighbors = (List<int>)Neigh(j); Point3d Centroid = new Point3d(); List<Point3d> NPts = new List<Point3d>(); foreach (int neighbor in Neighbors) { Centroid = Centroid + Pts(neighbor); NPts.Add(Pts(neighbor)); } Centroid = Centroid / Neighbors.Count; RectangularMatrix CiCBar = new RectangularMatrix(3, Neighbors.Count); for (int k = 0; k <= Neighbors.count - 1; k++) { point3d Diff = Pts(Neighbors(k)) - Centroid; CiCBar(0, k) = Diff.X; CiCBar(1, k) = Diff.y; CiCBar(2, k) = Diff.z; } CovM = CiCBar.MultiplySelfByTranspose(); CovM = (1 / (Neighbors.count - 1)) * CovM; CovMatrices.Add(CovM); } A = CovMatrices(0).ToArray(); C = CovMatrices; }
  • 40. 40Challenge the future Part 2 finished Some hints on previous assignment follow…
  • 41. 41Challenge the future Grid Surface Reconstruction Pseudo-Code Define a new Mesh with a list of Vertices and a list of Faces Mesh.Vertices=Points For j as Integer=0 to V-2//choose only bottom-left corners as pivot points For i As Integer=0 To U - 2 define n0,n1,n2,n3 As Integer n0 = j * U + I //bottom-left n1 = n0 + 1 //bottom-right n2 = n0 + U //top-right n3 = n1 + U //top-left Define face As new MeshFace(n0, n1, n3, n2) Mesh.Faces.AddFace(face) Next Next
  • 42. 42Challenge the future Grid Surface Reconstruction VB.NET Dim M As New Mesh M.Vertices.AddVertices(P) If Not C Is Nothing Then M.VertexColors.AppendColors(C.toArray) For j As Integer=0 To V - 2 For i As Integer=0 To U - 2 Dim n0,n1,n2,n3 As Integer n0 = j * U + i n1 = n0 + 1 n2 = n0 + U n3 = n1 + U Dim face As MeshFace = New MeshFace(n0, n1, n3, n2) M.Faces.AddFace(face) Next Next with two nested loops
  • 43. 43Challenge the future Grid Surface Reconstruction VB.NET Dim M As New Mesh M.Vertices.AddVertices(P) If Not C Is Nothing Then M.VertexColors.AppendColors(C.toArray) For i As Integer=0 To U * (V - 1) - 1 If (i Mod u) < u - 1 Then Dim n0,n1,n2,n3 As Integer n0 = i n1 = n0 + 1 n2 = n0 + U n3 = n1 + U Dim face As MeshFace = New MeshFace(n0, n1, n3, n2) M.Faces.AddFace(face) End If Next with one loop
  • 44. 44Challenge the future Grid Surface Reconstruction C#.NET Mesh M = new Mesh(); M.Vertices.AddVertices(P); if ((C != null)) M.VertexColors.AppendColors(C.toArray); for (int i = 0; i <= U * (V - 1) - 1; i++) { if ((i % u) < u - 1) { int n0 = 0; int n1 = 0; int n2 = 0; int n3 = 0; n0 = i; n1 = n0 + 1; n2 = n0 + U; n3 = n1 + U; MeshFace face = new MeshFace(n0, n1, n3, n2); M.Faces.AddFace(face); } } with one loop
  • 45. 45Challenge the future Simple Estimation of Normal Vectors Pseudo-Code Form an empty list of normal vectors Define deviation as a double For each point as Point3d in the point cloud find neighbors fit a plane to neighbors Get the normal of this plane and put it out as the normal of the point form a vector from the vantage point VP to point=VP-point and call it dir if this normal.dir>0 then Add the normal to the list of normals Else Add –normal to the list of normals End Next
  • 46. 46Challenge the future Estimation Normal Vectors C#.NET List<Vector3d> Normals = new List<Vector3d>(); Point3dList PCList = new Point3dList(); PCList.AddRange(x); double Dev = MD; foreach (Point3d point in PCList) { dynamic Neighbors = PCList.FindAll(V => V.DistanceTo(point) < D); plane NP = default(Plane); Plane.FitPlaneToPoints(Neighbors, NP, Dev); if (NP.Normal * (VP - point) > 0) { Normals.Add(NP.Normal); } else { Normals.Add(-NP.Normal); } } A = Normals; B = PCList.FindAll(VT => VT.DistanceTo(x(654)) < D);
  • 47. 47Challenge the future Estimation Normal Vectors VB.NET Dim Normals As New list(Of Vector3d) Dim PCList As New point3dlist PClist.AddRange(x) Dim Dev As Double = MD For Each point As point3d In PClist Dim Neighbors = PClist.FindAll(Function(V) V.distanceto(point) < D) Dim NP As plane Plane.FitPlaneToPoints(Neighbors, NP, Dev) If NP.Normal * (VP - point) > 0 Then Normals.Add(NP.Normal) Else Normals.Add(-NP.Normal) End if Next A = Normals B = PClist.FindAll(Function(VT) VT.DistanceTo(x(654)) < D)
  • 48. 48Challenge the future Basics of Scripting in Rhino + GH • VB.NET (Sub[routine], Function, ByVal, ByRef) • C#.NET (Void, [Functions], [val],ref) • Python (defs) Basic concepts of systems and modules, Inputs & Outputs Private Sub RunScript(ByVal x As Object, ByVal y As Object, ByRef A As Object) End Sub '<Custom additional code> '</Custom additional code> Function plus(A As Integer, B As Integer) As Integer Return A + B End Function private void RunScript(object x, object y, ref object A) { } // <Custom additional code> // </Custom additional code> public int plus(int a, int b) { return a + b; } def plus(a,b): return a+b Nothing visible.
  • 49. 49Challenge the future Basics of Scripting in Rhino + GH • Rhinocommon • Rhinoscript • Grasshopper Kernel Rhinocommon Library of Geometry Operations VB.NET. C#.NET & Python Grasshopper Kernel Library of Some Special Geometry Operations VB.NET. C#.NET & Python Rhionscript (with [Iron]Python) Operations as in Rhino Command Line Python http://4.rhino3d.com/5/rhinocommon/Rhinocommon SDK: Grasshopper SDK: [Rhino]Command: GrasshopperGetSDKDocumentation Rhinoscript Syntax SDK: [GH Python]Help: Rhinoscript syntax help
  • 50. 50Challenge the future Questions? p.nourian@tudelft.nl • I will give you the tools we have developed so far as open source; • You will make them better using the following libraries; • Using either Math.NET or MetaNumerics is a must; • Using Accord.NET is a big plus! • If you are using Python, use similar libraries such as SciPy • If you want to do something else let us discuss it now!