Advanced CAD-Geometric Modeling-Transforms
Advanced CAD-Geometric Modeling-Transforms
2. Geometric Modeling,
3. Transformations
Hikmet Kocabaş, Prof., PhD.
Istanbul Technical University
Lectures, Outline of the course
1 Advanced CAD Technologies, Hardwares, Softwares
2 Geometric Modeling, 2D Drawing
3 Transformations, 3D
4 Parametric Curves
5 Splines, NURBS
6 Parametric Surfaces
7 Solid Modeling
8 API programming
Why Study Geometric Modeling
The knowledge of the geometric modeling entities
increase your productivity.
Understand how the math presentation of various
entities relates to a user interface.
Understand what is impossible and which way can be
more efficient when creating or modifying an entity.
Control the shape of an existing object in design.
The storage, computation and transformation of
objects. Calculate the intersections and physical
properties of objects.
Geometric Modeling is important
• to meet certain geometric requirements
• such as slopes and/or curvatures in model
• interpretation of unexpected results
• evaluations, simulations of CAD/CAM systems cutting
• use of the tools in particular (robotic) applications
• creation of new attributes
• modify the obtained models
Geometric Modeling in CAD
Geometric modeling is only a means not the goal in
engineering. Engineering analysis needs product
geometry; the degree of detail depends on the analysis
procedure that uses the geometry.
Basic Elements of a CAD System
.
Fundamental Features
• Geometry: Position, direction, length, area, normal,
tangent, etc.
• Interaction: Size, continuity, collision, intersection
• Topology
• Differential properties: Curvature, arc-length
• Physical attributes
• Computer representation & data structure
• Others…
Professional CAD/CAE/CAM products
Unigraphics (UGS), NX (EDS)
I-DEAS (SDRC)
Pro/Engineer, Pro/Mechanica, Pro/E, Creo (PTC)
AutoCAD (AutoDesk, Inventor)
ANSYS (ANSYS Inc.)
CATIA, Delmia, SolidWorks (Dassault Systemes - IBM)
Nastran, Patran (MacNeal-Schwendler)
…
SurfCam, Solid Edge (EDS), MicroStation, Intergraph,
CADKey, DesignCAD, ThinkDesign,
3DStudio MAX, Rhinoceros, …
AutoCAD
A world’s leading PC-based 3D mechanical design
package, from AutoDesk Inc.
Used to be the primary PC drafting package (dealer, PC)
The world’s most popular CAD software due to its lower
cost and PC platform
New features:
• ACIS 3.0 Advanced Solid Modeling Engine
• NURBS Surface Modeling
• Robust Assembly Modeling and Automated Associative
Drafting
Flexible programming tools, AutoLISP, ADS and ARX
Integrated CAD/CAM Tools
ANSYS (from ANSYS Inc.)
• A growth leader in CAE and integrated design
analysis and optimization (DAO) software
• Covering solid mechanics, kinematics, dynamics,
and multi-physics (CFD, EMAG, HT, Acoustics)
• Interfacing with key CAD systems
NASTRAN (from MacNeal-Schwendler): PATRAN
provides an open flexible MCAE environment for
multidisciplinary design analysis.
Pro/MECHANICA (integrated with Pro/E)
Integrated CAD/CAM Tools
SURFCAM (from Surfware Inc. CA)
• An outgrowth of the Diehl family’s machine shop
• A system for generating 2~5- axis milling, turning,
drilling, and wire EDM.
• Toolpath verification (MachineWorks Ltd.)
Surfaces
have no thickness,
no volume or solid properties.
Changes
Model
Drawing
Drawing Set Up and Layout
• Drawing Size
• Drawing Projection Angle
Selected views
• Front
• Top
• Right
• Isometric
Generic CAD Process
.
CAD Software, Graphic User Interface
Geometrical model
2D/3D
Exact or faceted with planar polygons
Mass properties
Editing
Parametric
Object Organization
Named Objects
Layers
Part libraries
Drawing Output
Drafting module
CAD Software, Graphic User Interface
Analysis Module
Finite Elements
Plastic Flow
Kinematics/Collisions
Dynamics
Importing/Exporting
Surface formats: IGES, DXF, CDL
Solid Formats: PDES/STEP, ACIS, SAT
Files for systems such as NASTRAN
Can be linked to a user written program
Rendering
Hidden line
Shaded Image
Ray Tracing
Real Time Rotations
Graphics Standards
(GKS, PHIGS, OpenGL, IGES, PDES, STEP, DWG, DXF,
Parasolid, ACIS,…)
Graphics Standards
Several graphics standards have been developed over
the years, including CORE (1977-1979),
GKS (Graphical Kernel System, 1984-1985),
GKS-3D (added 3D capabilities),
PHIGS (Programmer’s Hierarchical Graphics sys.1984),
PHIGS+ include more powerful 3D graphics functions,
X-Windows system (1987), and
OpenGL is adapted from Unix system.
DirectX (1994) API developed by Windows for 3D
animation.
IGES, STEP, ACIS data exchange formats
.
IGES, STEP, PDES, Parasolid formats
IGES (Initial Graphics Exchange Specification) initially
published by ANSI in 1980. Version 5.3 (1996) is the last.
STEP (STandard for the Exchange of Product model data)
(ISO 10303) released in 1994. A neutral representation of
product data. Every year new parts are added or new
revisions of older parts are released. This makes STEP the
biggest standard within ISO.
PDES (Product Data Exchange Specification, PDDI)
originated in 1988 by McDonnell Aircraft Corporation.
Parasolid (owned by Siemens) can represent wireframe,
surface, solid, cellular and general non-manifold models.
It stores topological and geometric information defining
the shape of models in transmitting files.
Solid modeling techniques
Sweeping,
Half Spaces,
CSG,
B-rep
Migration of standards towards STEP
.
STEP configuration controlled 3D Design
(Standard for the Exchange of Product model data)
STEP is also referred as ISO 10303. (start.1984..1994…)
https://cadexchanger.com/step
STEP, BREP: Boundary Representation
B-rep represent solids by their surfaces
Vector versus Raster Graphics
.
Raster Graphics
Tessellation
Sampling & Antialiasing
P2 (x2 ,y2)
P(u)= (x,y)
P1 (x1 ,y1)
Curve representation
equations
There are two types of curve equations
(1) Parametric equation
x, y, z coordinates are related by a parametric
and independent variable (u, θ or t)
Point on 3-D curve: p = [x(u) y(u) z(u)]
Point on 2-D curve: p = [x(u) y(u)]
(into screen)
Points, Vectors and Coordinate Systems
The Cartesian coordinates (x, y, z) are the distances of
the vertex with respect to the coordinate system we
defined.
Unit Vectors
A unit vector is a vector whose
length equals unity.
Vectors
A vector can be pictured as a line segment of definite
length with an arrow on one end.
We will call the end with the arrow
the tip or head
and the other end the tail.
Equivalent Vectors
Two vectors are equivalent if they have the same
length, are parallel, and point in the same direction
(have the same sense) as shown in Figure.
Unit vectors
The symbols i, j, and k denote vectors of “unit length”
(based on the unit of measurement of the coordinate
system) which point in the positive x, y, and z
directions respectively (see Figure). Unit vectors allow
us to express a vector in component form
P = (a, b, c) = ai + bj + ck
Unit Vectors
A unit vector is a vector
whose length equals unity.
Points and Vectors
An expression such as (x, y, z) can be called a triple of
numbers. A triple can signify either a point or a vector.
Relative Position Vectors Given two points P1 and P2,
we can define P2/1 = P2 − P1
as the vector pointing from P1 to P2. This notation
P2/1 is widely used in engineering mechanics, and can
be read “the position of point P2 relative to P1”
(see Figure).
The distance between two points
In a Euclidean space we define the distance between
two points p and q as the norm of the vector p – q.
.
Vector Algebra
Given two vectors P1 = (x1, y1, z1) and P2 = (x2, y2, z2),
the following operations are defined:
Addition:
P1 + P2 = P2 + P1 = (x1 + x2, y1 + y2, z1 + z2)
Subtraction:
P1 − P2 = (x1 − x2, y1 − y2, z1 − z2)
Vector Algebra
Using matrix notation a
Vector can be written as
x = x1e1 + x2e2 +…+ xnen
x = EX.
The correspondence between vectors and matrices
preserves addition and multiplication by a scalar.
The matrix Z that corresponds to the sum of two vectors
z = x + y is the sum
Vector Algebra
For multiplication by a scalar, Z = a X, or
cP1 = c (x1 , y1 , z1) = (cx1 , cy1 , cz1)
e 1 × e2 = e3
e2 × e 3 = e 1
e3 × e 1 = e 2
Vector (Cross) Product
Cross Product: The cross product P1 × P2 is a vector
whose magnitude is
|P1 × P2| = |P1||P2| sinθ
P2
Area
P1 P3
Cross Product, Area of a Triangle
For example, the area of a triangle with vertices
P1 = (1, 1, 1), P2 = (2, 4, 5), P3 = (3, 2, 6) is
P2
Area
P1 P3
Parametric equation of Line
A line can be defined using either a parametric
equation or an implicit equation.
In vector form,
Parametric equation of Line
In this equation, A0 is a point on the line and
A1 is the direction of the line.
0
P(t0=0) P(t) P(t1=1)
P0 P1
Linear interpolation
Line
(Combinations of Points) t (P2 - P1) P P2
• Let P1 and P2 be points in space. P1+ t (P2 - P1)
• if 0 ≤ t ≤ 1 then P is somewhere P1
on the line segment joining P1 and P2 .
• We may utilize the following notation
t 1 α2= t
P = P(t) = (1 - t) P1+ t P2 1
t α1= 1- t
• We can then define a combination t0 0
of two points P1 and P2 to be P1 Linear P2
P = α1 P1+ α2 P2 where α1 + α2 = 1 interpolation
• derive the transformation by setting α2 = t
Linear Parametric Plane Surface
We can generalize the line to define
a combination of an arbitrary number of points. 1 P2
P = α1 P1+ α2 P2 + α3 P3 P4
α3 (P3 - P1)
where α1 + α2 + α3 = 1
0 ≤ α 1 , α2 , α 3 ≤ 1 α2 (P2 - P1)
Illustration shows the α2
point P generated when
α2 = 1/4 , α3 = 1/2 ,
0 P
P1 0 α
α1 = 1 - α2 - α3 = 1/4 . 3
1 P3
Then, each vertex of our triangle could be
described in terms of its respective distance
from the two walls containing the origin (P1) and from the floor.
P = P1+ α2 (P2 - P1) + α3 (P3 - P1) P(u,v) = (1- u -v) P1+ u P2 + v P3
Convexity
A convex object is one for which any point
lying on the line segment connecting any
two points in the object is also in the object
P = α1 R+ α 2 Q & α1+α 2 = 1
• .
Combining Transformations
Example: Transformation of the House
Original House: Goal:
Transformation Composition:
Rotation about a fixed point
Transformations
For rotation – implicit point
– origin
– 2D – simple
– 3D – complicated
Transformation
– rigid-body
– non-rigid-body Right Handed System
Z axis represents depth
When looking “down”
at the origin,
Positive rotation
is CCW.
Homogeneous
Transformations Matrix
Combining
Transformations
P = [x, y, z, 1]T
Homogeneous 3D Translation Matrix
y
Translation x′= x + t x
t=(tx , ty , tz) P′=P+t
y′= y + t y P′=T.P
( x′, y′, z′ ) z ′= z + t z
t
( x, y , z )
x′ 1 0 0 tx x
z x y′ 0
1 0 t y y
= ⋅
z′ 0 0 1 tz z
1 0 0 0 1 1
Translation of a Curve
x' 1 0 0 tx x
y ' 0 1 0 t y y
= ⋅
3D Homogenous translation z ' 0 0 1 tz z
1 0 0 0 1 1
3D Transformations: Scale & Translate
Scale, Parameters
for each axis direction
P′ = S.P
Translation
P′ = T.P
P = [x, y, z, 1]T
P′ = P + d
2D homegenous Translation
Scaling
.
Scaling
.
Homogenous 3D Scaling matrix
y y
x′= x ⋅ S x
y′= y ⋅ S y
z ′= x ⋅ S z
z x z x
Enlarging object also moves it from origin
x′ S x 0 0 0 x
y′ 0 Sy 0 0 y
P′ = = ⋅ =⋅
S P
z′ 0 0 Sz 0 z
1 0 0 0 1 1
Scaling with respect to a fixed point
(not necessarily of object)
y y y
(x f , yf , zf ) (x f , yf , zf ) (x f , yf , zf )
z x z x z x
y Sx 0 0 (1 − S x ) x f
T ⋅ S ⋅ T−1 = 0 Sy 0 (1 − S y ) y f
0 0 Sz (1 − S z ) z f
0
(x f , yf , zf ) 0 0 1
z x
Rotation of a point about z axis
.
cos θ − sin θ 0 x cos θ × x − sin θ × y
2D Rotation sin θ
cos θ 0 × y = sin θ × x + cos θ × y : v' = R (θ )v
0 0 1 1 1
Scaling
1 0 t2 x 1 0 t1x 1 0 t1x + t2 x
0 1 t ⋅ 0 1 t =0 1 t + t
2y 1y 1y 2y
T ( t2 x , t2 y ) ⋅ T ( t1x , t1 y ) =T ( t1x + t2 x , t1 y + t2 y )
Composite Rotations:
P′ R (θ 2 ) {R (θ1 ) ⋅ =
= P} {R (θ ) ⋅ R (θ )} ⋅ P
2 1
R (θ 2 ) ⋅ R (θ1 ) =R (θ1 + θ 2 )
P′= R (θ1 + θ 2 ) ⋅ P
Combining Transformations
The three transformation matrices are combined as
follows
1 0 − dx cos θ − sin θ 0 1 0 dx x
0 1 − dy × sin θ cos θ 0 × 0 1 dy × y
0 0 1 0 0 1 0 0 1 1
y
θ
n
z
x
Rotation about an axis n (nx ,ny ,nz) by angle θ
.
Rotation around an Arbitrary Axis
.
CAD CAM -
Ibrahim Zeid ,
p. 495 & 496
0
Rotation around
an Arbitrary Axis
.
CAD CAM -
Ibrahim Zeid ,
p. 495 & 496
u’z
y u’y
Other rotations z u’x
x
What if the axis of rotation
does not pass through the origin?
P ( x, y ) P′ = Pr + R ⋅ ( P − Pr )
θ
cos θ − sin θ
Pr ( xr , yr ) x R=
sin θ cos θ
Rotation about a fixed point, M=T.R.T-1
Move to origin Rotate Move back
( xr , yr )
M=TRS
(order is substantial!)
Composite Rotations in E3
• .
Rz Rx
⇓
Cube can be rotated about all
x, y, z axis
In our case the transformation
matrix is defined
M = Ry Rx Rz= Rzx Ryz Rxy
Ry
Rotations About an Arbitrary Axis
Given:
• points p1 , p2 and rotation angle θ
• objects to be rotated
Define vectors
u = p1 - p2
and v = u / |u| – normalized
v = [ αx , αy , αz ]T
αx2 + αy2 + αz2 = 1 – directional cosines
cos( ϕx ) = αx , cos( ϕy ) = αy , cos( ϕz ) = αz
cos2( ϕx ) + cos2( ϕy ) + cos2 ( ϕz ) = 1
⇒ only two directions angles are independent !!
Rotations About an Arbitrary Axis
General 3D Rotation
Translate to origin. Rotate on Cartesian axes.
y y y
P2
P2′
θ
P1
P1′ P1′
x x x
P2′′
z z z
Rotation about the axis. Apply inverse translations.
y y y
P2′ P2
P1′ P1′ P1
P2′′ x x x
θ
z z z
T−1 ⋅ R −x 1 (α ) ⋅ R −y1 ( β ) ⋅ R z (θ ) ⋅ R y ( β ) ⋅ R x (α ) ⋅ T
R (θ ) = y
P2
1 0 0 − x1
Translate the object to origin. 0 1 0 − y1 P1
T=
.The vector from P to P is: 0 0 1 − z1 x
1 2
0 0 0 1 z
V = P2 − P1 = ( x2 − x1 , y2 − y1 , z2 − z1 )
y
P2′
=
Unit rotation vector: u V=
|V| ( a, b, c ) P1′
x
= ( x2 − x1 ) y
a |V| u = ( a , b, c ) z y
=
b ( y2 − y1 ) |V|
=
c ( z2 − z1 ) |V| x P1′
P2′′ x
a 2 + b2 + c2 =
1 z
z
Rotating u to coincide with z axis
α c
cos= b 2 + c=
2
α b d.
c d , sin =
hence z − component is b 2 + c 2 =
d. cos β = d , sin β = −a
y
d 0 a 0 u = ( a , b, c )
0 1 0 0
Ry (β ) = d
−a 0 d 0 1
0 0 0 1 α x
β 1
z d
w = ( a, 0, d )
T−1 ⋅ R −x 1 (α ) ⋅ R −y1 ( β ) ⋅ R z (θ ) ⋅ R y ( β ) ⋅ R x (α ) ⋅ T
R (θ ) =
1 0 0 0 d 0 a 0 cos θ − sin θ 0 0 d 0 a 0 1 0 0 0
0 sin θ 0 c d 0
0 c d −b d 1 0 0 cos θ 0 0 0 1 0 0 −b d
R x (α ) =
0
R x (α ) = Ry (β ) = R z (θ ) = Ry (β ) =
0 b d c d 0 −a 0 d 0 0 0 1 0 −a 0 d 0 0 b d c d 0
0 0 0 1 0 0 0 1 0 0 0 1
0 0 0 1 0 0 0 1
General 3D Rotation Matrix
y
cos θ − sin θ 0 0 P2
sin θ cos θ 0 0 θ
R z (θ ) =
P1
0 0 1 0 x
0 0 0 1 z
T−1 ⋅ R −x 1 (α ) ⋅ R −y1 ( β ) ⋅ R z (θ ) ⋅ R y ( β ) ⋅ R x (α ) ⋅ T
R (θ ) =
1 0 0 0 d 0 a 0 cos θ − sin θ 0 0 d 0 a 0 1 0 0 0
0 sin θ 0 0 c d 0
0 c d −b d 1 0 0 cos θ 0 0 1 0 0 −b d
R x (α ) =
0
R x (α ) = Ry (β ) = R z (θ ) = Ry (β ) =
0 b d c d 0 −a 0 d 0 0 0 1 0 −a 0 d 0 0 b d c d 0
0 0 0 1 0 0 0 1 0 0 0 1
0 0 0 1 0 0 0 1
M R (θ ) =
• .
2D Reflections (Mirror)
2D reflection about x, y, (x and y) axis :
y y y
x x
x
1 0 0 −1 0 0 −1 0 0
0 −1 0 0 1 0 0 −1 0
0 0 1 0 0 1 0 0 1
3D Reflection (Mirror)
3D Reflection
about x-y plane :
the mirror of P
P* = M P
Complete transformation
M = T(p0) Rx(-θx) Ry(-θy) Fz(-z) Ry(θy) Rx(θx) T(- p0)
3D Transformations: Shear
3D Shear:
(function of z)
Orthographic projection matrices
.
Perspective projection
Figure shows how to project a point on the y axis from
a center of projection v lying on the x axis at x=d. By
similarity of triangles. Thus far we have only used
homogeneous matrices with a last row whose
offdiagonal elements are null. What happens when
they are non-null (–1/d) term. After normalizing the
result, we obtain perspective projection of the object.
Perspective projection
Computing a planar projection
involves matrix multiplication,
followed by normalization and orthographic projection
(z=0 plane). ( r = –1/d )
3D Perspective
In 3-D, the matrix multiplication
provides us the x and y coordinates
of the projection of a point on the xy plane,
from a center of projection on the z axis at z=d.
In 3-D the perspective transformation produces
a deformed 3-D object, which must be projected
orthographically onto the xy plane to generate the
desired 2-D image. Computing a planar projection
involves matrix multiplication, followed by
normalization and orthographic projection.
3D Perspective
.
Parametric Circle
Parametric Circle
.
Other Parametric Curves
.
2D CAD
APT Statements
Circle defined by diameter P1 P2
Circle radius R and center Pc are
Circle passing through three points
Circle center Pc is the
intersection of the
perpendicular lines to
the chords P1P2 , P2P3 ,
P2P1 from their
midpoints P6 , P4 , P5 .
Circle passing through three points
.
Circle passing through three points
.
Circle passing through three points
For 2D case:
Circle tangent to two lines with a given R
The center of the circle is
the intersection point of
two offset parallel lines
with radius R distance.
The parametric vector equations
of parallel lines