CHAPTER 1

INTRODUCTION TO COMPUTER AIDED DESIGN

Computer Aided Design, which is currently known as CAD, is in fact the integration of computer , geometric modeling, and design. provides the visualization techniques. Geometric modeling provides the platform for modeling purposes, whilst the design is a process to come up with certain design. CAD is applicable to many areas, however the scope of CAD in this book is focused on the application to mechanical engineering.

1.1 HISTORY OF CAD

The invention of SKETCHPAD in 1962 remarks the birth of CAD. Before the invention of SKETCHPAD, computer has been used for numerical simulation using keyboard and punch card. With the invention of SKETCHPAD by in

MIT Lincoln Laboratory, for the first time human can give command to computer using light pen. In fact, the using light pen was firstly done with the invention of SKETCHPAD.

Push button technique is used to give command to the computer and the geometrical input can be done using light pen. The invention of SKETCHPAD was in fact contributed to many new inventions, constraint based drawing, 3D solid model with the ability to hide the hidden edges, and even hierarchical data structure that have been implemented in object oriented programming.

Throughout the 1960s, companies were interested to develop the CAD software for their own companies such as CADD by Mc-Donnell Douglas, CADAM 1-1

by Lockheed etc. In Europe, researchers were focused on the development of 3D complex curve and surface formation, such development of Bezier curve based on the inventor name at Renault become the breakthrough in the development of algorithm for complex curve.

At the late 1960, the development of the commercialized CAD packages becomes the interest. Avions Marcel Dassault, a French aerospace company in 1975, purchased a source-code license of CADAM from Lockheed to develop 3D CAD software program that was named as CATIA (Computer Aided Three Dimensional

Interactive Application).

In 1970s, the development of solid modeling becomes the research interest.

The introduction of Constructive Solid Geometry (CSG) and Boundary

Representation (BReps) were the core for PADL and BUILD solid modeler respectively. Later in 1980s, most commercial CAD packages started to use these modelers for their solid kernel. Then the development of CAD packages relies on the development of the platform; mainframe (late 1970s), Unix Workstation (first half of

1980), and Windows NT (early 1990s).

With the invention of Unix system, the parametric modeling becomes reality as its first concept introduced by SKECTCHPAD. Amongst the leading vendors are

Computervision (CADDS), Intergraph (IGDS and InterAct), McDonnell-Douglas

(Unigraphics), GE/CALMA, IBM/Dassault (CADAM and CATIA), SDRC (I-DEAS) and Parametric Technology (Pro/Engineer). These vendors were supported by B-Reps solid kernel developer such as Spatial Technology (ACIS), EDS-Unigraphics

(Parasolid) and Ricoh (Designbase).

1-2

When Microsoft developed Windows NT and Intel developed Pentium processor with 32 bits capability, PC has now the capability to run parametric solid modeler and this cause the CAD industry to be totally revolutionized.

In 1993, Jon Hirschtick developed SolidWorks based on windows platform with the aim to make 3D CAD technology more accessible. Then 1995, SolidEdge become the competitor to SolidWork and 1999 CATIA is fully implemented using

Windows NT based.

The trend of parametric modelling has extended to include the usage of tool to keep track the data related to particular model as it is called as Product Data

Management (PDM). The PDM will include technical specifications of the product, specifications for manufacture and development, and the types of materials that will be required to produce goods.

In the early 2000’s, full-fledged CAD packages with the integration of design process is implemented. Start with concept, and finally engineering analysis and manufacturing have been integrated and this reduces the time taken for design. Then,

Product Lifecycle Management (PLM) is integrated to the CAD packages to manage the entire lifecycle of a product efficiently and cost-effectively, from ideation, design and manufacture, through service and disposal.

Currently, CAD packages can be divided into three categories; upper range price packages (CATIA, Unigraphics, etc), mid range price packages (Solidworks,

Inventor, etc) and freeware CAD packages (CadStd, CADVANNCE, etc).

1-3

1.2 CAD IN DESIGN PROCESS

When talking about design, it is eventually talking about design process. Figure 1.1 shows the design process. Design starts with problem or need. When the need has been defined, a research background is carried out. The objective of the research background is to have in depth understanding related to the needs. The research background should come out with product design specification (PDS). PDS is the boundary of the design, all the concepts that will be developed in the next step must fulfill all the statements in the PDS.

When PDS is developed, now it is the time to develop the solutions or most people will say design concepts. Important to mention here that the more solutions are, the better will be the final design. The key of producing a good solution is to have larger number of solutions to be considered.

Then the the final appropriate design is selected. This final design can one of the designs or a new design resulting from the combination of two or more design. A good method to select final design should allow the design to be combined with other design to give more alternative designs.

After the final design is developed, then detail design is carried out prior the development of the prototype. At this stage, a number of tools can be applied such as

Design for Manufacturing and Assembly (DFMA), Failure Mode Effect Analysis

(FMEA), or Value Engineering. Engineering analysis on the part of the design is also done at this stage. This stage will ensure every consideration has been taken into account. Then, the design is built and a number of testing is carried to ensure the final product serves its initial needs. Then, the engineering drawing, is produced as the final documentation to allow the design to be fabricated and manufactured. 1-4

Figure 1.1 Design Process

1.2.1 APPLICATIONS OF CAD

Following will discuss the engineering applications of the CAD.

1.2.1 Modeling

Most users use CAD packages to model parts and even the whole assembly of the design. Currently, parametric modeling becomes the modeling method adopted by most CAD packages. Even the drafting software has started to introduce parametric modeling, such as it has been introduced in AutoCAD 2012.

The modeling process starts with part model, and then a number of parts will be assembled to produce assembly model. Based on the part and assembled part, a complete documentation include detail and production drawing can be generated.

Since all the files, part, assembly and drawing files, are linked to each other, any changes that is carried out on one of the files will cause similar alteration to be done on other files.

To link between part and documentation, concept of work space and paper space is well adopted. The difference between the CAD packages, the implementation

1-5

of the concept. AutoCAD implements the concept in a single file, whilst most of the other CAD packages uses different file format in the implementation of the concept.

1.2.2 Design Review and Evaluation

Each model comprises the geometrical properties and attributes. Geometrical properties will ensure the spatial requirement for the model, whilst attributes will keep the properties of the model such as material, surface texture, or color. Both the geometrical properties and attributes of the model are the properties of the model and these properties are retrievable. Retrievable properties will allow the user to review and evaluate the design. For instance, mass and centroid of the parts are amongst the essential information to analyze the part.

Even some of the modeling techniques are adopted from specific applications such as sheet metal, weldment, and mold. As such, when the model is created using sheet metal method, the model should be created based on base flange, then process such as folding or bending can be applied to create final part.

In addition to the method of modeling based on the applications, models can also be reviewed whether it can be produced using the intended application. As such,

CAD packages will indicate whether the specific model on the parts can be produced by certain machining process.

Most of CAD packages provides features for user to review and evaluate the the part as well as assembled model. Interference checking is used to check whether the part will obstruct other part or will be obstructed by other parts.

1.2.3 Full fledged design platform

1-6

When PDM and PLM are integrated to the model, CAD packages become the tool for full-fledged design platform. It commences from the modeling and follows with the design review and evaluation of the part and assembled model. Finally engineering analysis on design is carried out to ensure reliability of the design.

Currently, motion analysis and finite element analysis becomes common features in most of CAD packages. Motion analysis will focus on the kinematics and dynamic effect of the parts when the assembly model in operation. Most of the application is moving part such as mechanism, piston etc.

FEA will analyze the part when the load is applied to part during operation.

Hence, all the related parameters on the design can be determined and geometrical properties of the design can be finalized.

Nowadays, the modeling techniques to build the part are already established.

Therefore, vendors are now developed very specific engineering applications for the

CAD packages, as such human activity analysis becomes one of the applications for

CATIA software. In addition to the engineering analysis tool developed by the CAD vendor itself, other engineering analysis that is developed by third party is also available in the market. This third party software can be integrated to the CAD packages.

1.2.4 Automated Drafting and Modeling

Every CAD packages will come with Application Program Interface (API) as one of the features. The automation of drafting and modeling can be implemented by allowing the manual method of drafting or modeling to be done by the computers

1-7

through interface functions in API. This allows the users to replace the repetitive modeling part to be carried out automatically.

In certain cases, it requires engineering calculation to be carried out prior to modeling. Therefore, modeling using API programming is suitable to be adopted as both engineering calculation and modeling can be done by programming.

1.2.5 Design Wonder

The programming using API can be further extended to add intelligence to the system.

All the previous applications focus on the development of the model. For the purpose of the design wonder, the system should be able to read the model and used the information from the model for design purposes. One good example of the implementation design wonder in CAD is MIT sketching whiteboard. This MIT sketching whiteboard is shown in Youtube in 2006 (Figure 1.2) which is able to translate human sketch into motion simulation based on law of physics.

Figure 1.2: MIT Sketching Whiteboard

1.3 STANDARDIZATION IN CAD PACKAGES

This section discusses the foundation principles that govern the representation of the part. Section 1.3.1 will discuss the coordinate system (CS), starting with 2D CS and then follows with 3D CS. Then hand rule that governs these coordinate systems will be discussed in Section 1.3.2. Lastly, Section 1.3.3 will discuss the concept of plane and its principles in plane creation and application for modeling. 1-8

1.3.1 Coordinate System

Coordinate system (CS) will label certain point in space. With the CS, the position of every entity can be labeled and thus the position, movement or displacement can be calculated. As for the geometric modelling, CS becomes an important element.

There are many CSs available and each of them will have specific purpose.

There is a number of CS types that are commonly being used in CAD, namely;

Cartesian, Cylindrical and Spherical CS. The following discusses each of the CS in

2D plane and 3D environment.

2D Plane CS

2D plane CS describes the position of the point in 2D plane. There are two type 2D plane CS which is Cartesian and Cylindrical CS. i) Cartesian CS

Cartesian CS is labeled by two components in form of (x, y). x is the coordinate along the X axis based on the horizontal distance in unit from the origin, whilst y is the coordinate along the Y axis based on the vertical distance in unit from the origin. For instance, point A and B are represented as (2,1) and (3,5) respectively as shown in

Figure 1.3.

Figure 1.3: Cartesian 2D coordinate

1-9

ii) Cylindrical CS

Cylindrical CS is founded by the circle that is formed by the point when the origin will be the center of the circle. The point will be described by the radius of the circle and the angle measured from the reference axis to the point. Therefore, cylindrical CS will be labeled as (R, ) as shown in Figure 1.4.

Figure 1.4: Polar cylindrical CS

When the Cylindrical CS is mapped to the Cartesian CS, equations that govern the relationship between both CSs can be developed. Equation 1.1 and 1.2 will govern the relationship between x and y coordinate of Cartesian CS and the Cylindrical CS.

Figure 1.5 illustrates these equations graphically

x = R cos  … (1.1)

y = R sin     

Figure 1.5: Relationship between polar cylindrical and Cartesian CS

1-10

Example 1.1

Fill in the blanks below to complete the Cartesian - Cylindrical Polar Coordinates

Conversion Table.

Table 1

Cartesian Coordinate Cylindrical Coordinate

(-10, 70) (a)

(b) (12, 500)

(-5, (c) ) (13, (d) )

Answer a) To define the Cylindrical CS, radius R and angle  should be calculated.

Radius : R  x2  y2  70.71

y Angle :   tan 1  81.9o x

When angle is negative, there are possible solutions which are the angel

measured will in the second and fourth quadrant. Since x coordinate is negative,

the angle must be in the second quadrant.

Therefore, angle:  180o  81.9o  98.1o

Ans: (70.71 , 98.1o )

b) Equation 1.1 and 1,2 will calculate the x and y coordinate respectively.

Therefore, ( x , y ) = ( 12 cos (50o) , 12 sin (50o) )

1-11

Ans: (7.71 , 9.19 ) c) When R = 13 and x = -5, y will y  R2  x2  12

Ans: y = 12 . -12

y d) Angle will be   tan 1 x

12 Since there are two solutions,   tan 1  67.4 , 1  5

12   tan 1  67.4 2  5

In the case of 1, the angle measured will be in the second quadrant

o o o Therefore 1 180  67.4 112.6

2 is measured at the third quadrant,

o o o Therefore, 2 180  67.4  247.4

Ans:  = 112.6o , 247.4o

3D Coordinate System

3D CS is in fact the extension of 2D plane CS and it is used to label the point in 3D environment. In the case of 3D CS, Spherical CS is the additional CS together with the previous Cartesian and Cylindrical CS. Following discusses in detail all the three

CSs. i) Cartesian CS

1-12

3D Cartesian CS is described by three components, (x, y, z). Similar to the definition of x and y coordinate, the z coordinate is the distance along the Z axis from the origin.

Figure 1.6 illustrates the definition of a point using 3D Cartesian CS.

Figure 1.6: 3D Cartesian CS ii) Cylindrical CS

Description of cylindrical CS in 3D environment has similar representation of cylinder. The bottom side of the cylinder is described using 2D cylindrical CS with additional height along the Z axis. Therefore, the cylindrical CS is represented as (R,

, z). Figure 1.7 demonstrates the cylindrical CS and its coordinates. As far as the relationship with Cartesian CS is concerned, only additional Z axis is added. The equations are as follows

x = R cos , … (1.3)

y = R sin     

z = z … (1.5)

1-13

Figure 1.7: 3D cylindrical CS iii) Spherical CS

Spherical CS describes a point using the representation of sphere. Two 2D cylindrical

CSs are combined to create a 3D space. The first cylindrical CS is on the horizontal plane, which is XY plane. The project point on XY will make angle with X axis.

The other cylindrical CS is perpendicular to the first plane and the plane will go through the point. Angle  is the angle of line from origin to point with Z axis. Figure

1.8 shows the both of the planes and the angle definitions.

Figure 1.8: Spherical CS

1-14

Finally the equations to relate between Cartesian CS and Spherical CS are as the following.

x  r sin( )cos() … (1.6)

y  r sin()sin() … (1.7)

z  r cos( ) … (1.8)

Example 1.2

Fill in the blanks to complete the Cartesian - Cylindrical Coordinates Conversion

Table.

Table 2

Cartesian Coordinate Cylindrical Coordinate Spherical Coordinate

(-5, -7, 5) (a) (b)

(c) (d) (40, 130o , 170o)

a) Cylindrical CS, radius and angle needs to be calculated

Radius: R  x2  y2  8.6

 7 Angle:   tan 1  54.5o  5

Since both x and y are negative, the angle must be measured at the third

quadrant, therefore  180o  54.5o  234.5o

z coordinate: z = 5

Ans: (8.6, 234.5o, 5)

1-15

b) Spherical CS, radius R angle  and  need to be calculated.

Radius will be R  x2  y2  z 2  9.9

z Angle  will be   cos1  59.7o r

Since z is positive,  = 59.7o

y Angle will be   tan 1  54.5o x

Since both x and y are negative, the angle must be measured at the third

quadrant, therefore  180o  54.5o  234.5.5o

Ans: (9.9, 59.7o , 234.5o )

c) Equation 1.6 – 1.8 are used to convert from Spherical CS to Cartesian CS.

x  r sin()cos()  40sin(130o )cos(170o )  30.2

y  r sin()sin()  40sin(130o )sin(170o )  5.3

z  r cos()  40cos(130o )  25.7

Ans: (-30.2 , 5.3 , -25.7 )

d) To convert from Spherical CS to Cylindrical CS, the Spherical CS must be

converted to Cartesian CS first and it is followed with the conversion from

Cartesian CS to Cylindrical CS

Conversion from Spherical CS to Cartesian has been carried out as in (c).

Therefore, the answer in (c) is in Cartesian CS should be converted to

Cylindrical CS.

1-16

Therefore, radius R and angle  should be calculated.

Radius will be R  x2  y2  (30.2)2  5.32  30.7

Angle  = of spherical CS:  = 170o

y Or by calculation   tan 1  9.9o x

Since x is negative, the angle is at second quadrant

Therefore,  180o  9.9o 170.1o

z coordinate z =-25.7

Ans: ( 30.7 , 170.1o, -25.7)

1.3.2 Rule to handle coordinate system

Most of CAD packages will follow the standard used in governing the CS. The first standard is the direction and position of the X, Y, and Z axis. When the principle axes are followed the standard, the direction either positive or negative distance can be set in the case linear distance is required. This is governed by Right Hand Rule to maintain the convention in angular measurement, whilst Curled Right Hand rule is used to set the angle convention according to the axis. Both hand rule will be discussed in the following.

Right Hand Rule

Right hand rule is used to set the direction of the X, Y, and Z axis. Figure 1.9 illustrates how the right hand rule governs the direction of the principle axes. Thumb will show the direction of X axis, whilst index and middle finger will govern the direction of Y and Z axis respectively. Using the right-hand rule, the direction of X, Y

1-17

and Z axis is known and at the same time, it will be used to set the convention of positive and negative distance.

Figure 1.8: Right-Hand Rule

Class discussion 1.3

Using Right-Hand Rule, label Y and Z axis based on the X axis for CS in Figure 1.9

(i) and (ii)

Figure 1.9: Class Discussion 1.1

Curled Right Hand Rule

1-18

Curled right hand rule will govern the direction of positive angle as illustrated in

Figure 1.10. The thumb finger will show the direction of the axis and the curled finger shows the positive angle measurement. Based on the curled finger, counter-clockwise will be the positive angle measurement. Even though, this direction can be normally being used to govern the direction of rotation, some CAD packages allow the user to set the positive direction of angle measurement.

Figure 1.10: Curled Right Hand Rule

Class discussion 1.2

The part has been rotated from its original position to the position shown in Figure

1.11i – 1.11iii. Based on the CS shown, determine the axis of the rotation and the angle of rotation for each case.

1-19

Figure 1.11: Class Discussion 1.2

1.4 3D SPATIAL UNDERSTANDING

3D spatial understanding is necessary prior to do modeling in 3D environment. The

3D spatial understanding covers the conversion between 3D model into its projection and vice versa, and prediction of shape when transformation is applied to the part.

The understanding to convert from 3D model to 2D projection is similar understanding needed in creating the orthographic projection in engineering drawing.

Similarly, the understanding of converting 2D model to 3D model is similar understanding in creating isometric projection from orthographic projection. The main idea is that the ability of the user to find the relationship between 2D projection and

3D model and vice versa. Figure 1.12 shows the requirement for the 3D understanding. The requirements are the ability to visualize 3D object into its 2D projection and vice versa.

1-20

Figure 1.12: 3D and 2D conversion

In CAD packages, transformation will be applied to model when modeling the part is carried out. Rotation is the most frequent transformation applied to the part, for example when the user wants to select the face that is hidden from the projection, the part must be rotated first. Therefore, user must able to predict the shape when the rotation is carried. Figure 1.13 illustrates the understanding needed for 3D understanding. Firstly, user must be able to identify the transformation needed to position the part as its intended position as shown in Figure 1.13a. Secondly, after the user is able to identify the transformation needed, the user must also have the ability to apply the transformation on the other part as demonstrated in Figure 1.13b

1-21

Figure 1.13: Ability to identify the transformation and its final visualization shape.

3D spatial understanding is applicable when modeling. When dealing in 3D projection, illusion effect of the entities is one of the contributing errors while modeling. Some examples of the illusion effect are the following

Entities that are drawn on different plane: This error is normally occurred when the

sweeping or lofting process. For instance, the spline in Figure 1.14 seems to be

on the plane that is perpendicular to plane where the profile is drawn.

However, when the objects are viewed using two or more views, it reveals that

the profile and the spline are on the same plane. Hence, sweeping process

cannot be carried out and the software will prompt the error.

Figure 1.14: Illusion of being on different plane

Two parts that are seemed to be closed to each other: From certain projections, two

parts seems to be closed to each other, but in reality they are far apart. Figure

1.15 shows that two parts seems to close to each other when the part is view

using isometric view. In fact, the parts are far apart when the view is set to top

view. Furthermore, due to the fact that the two parts are far apart, this cause

one the part to be lost in the viewing screen when the user rotates the viewing

projection.

1-22

Figure 1.15: Illusion of being closed to each other….

Therefore to handle the illusion effect during modeling, it is advisable for the user to rotate the viewing projection to allow the user to have better 3D spatial understanding.

1.5 CONTENTS OF THE BOOK

There are two objectives of this book. The first objective is to application of CAD packages for engineering purpose. This is discussed in Chapter 6. The second objective is to make the understanding on how the ‘design wonder’ system works and this is discussed in Chapter 7.

In order to achieve both aims, model representation, transformation matrices, and modeling techniques must be understood first. Chapter 2 will discuss the model representation. Chapter 3 discusses the transformation and its application. Chapter 4 discusses the parametric modeling and modeling technique. Chapter 5 discusses the neutral file with the aims to actual model representation which is theoretically discussed in Chapter 2.

1-23

CHAPTER 2

MODEL REPRESENTATION

This chapter will discuss the model representation. There are three types of model representation, which are wire frame, surface, and solid. Section 2.1, 2.2, and 2.3 discuss in detail each representation respectively. Finally, Section 2.4 will discuss the cloud geometric representation which the latest model representation.

Figure 2.1 shows the view at the cutting plane to illustrate graphically the difference between the wire frame, surface, and solid modeling. When wireframe model is been cut, points will be projected on the cutting plane as all the edges are made of wires. In the case of surface modeling which the part will be modeled using

‘skin’, lines will be projected on the cutting plane. Finally, when a solid part is been cut, the inner part with bounded edges of the part will be projected on the cutting plane.

Figure 2.1 Illustration of the model representations using sectional plane

2-1

Before proceed to the discussion of wire frame geometric modeling, the terminology of the wire frame presentation that is regularly been used in solid modeler and therefore, wire frame geometric modeler should be clarified.

The wire frame presentation is also been used as term to indicate the visualization method of the model on the screen. The available visualization methods of the model depends on the CAD system. The most common visualization is wireframe, hidden line visible, hidden line removed, and shaded as shown in Figure

2.2. This type presentation is just for visualization purposes. Despite these types presentation, the model is remained a solid model.

Figure 2.2: Various visualization techniques of solid model

On the other hand, wireframe representation is the representation. Wireframe model causes the part to be modeled as a network of connected wires. The following discussion is focussed on the wire frame representation which is the latter one.

2-2

2.1 WIREFRAME REPRESENTATION

This section will discuss the wireframe representation. The discussion starts with the types of entities in wireframe representation in Section 2.1.1 and then Sec 2.1.2 discusses the mathematics of the wireframe representation. Section 2.1.3 discusses in detail the curves. Finally, Section 2.1.4 discusses the disadvantages of wire frame representation.

2.1.1 Entities

Every model representation comprises entities. In wireframe representation, there are a number of entities. The entities are line, circle, arc, ellipse, and curve. Each entity is represented by the entity types and their geometry. Following shows the entities and their geometries

Line: the coordinate of start and end points (Figure 2.3a)

Circle: the center point and radius (Figure 2.3b)

Arc: the center point, start and end angle. However, the geometry of arc may vary

from one software to another such as the geometry of arc is the center point

and start and end points (Figure 2.3c)

Ellipse: the center point, major and minor radius. In some CAD packages, both ellipse

and circle will be user the same entity. Circle is created when the major and

minor radius is equal. (Figure 2.3d)

Curve: is represented by the list of vertices and the vector controls each vertices.

(Figure 2.3e)

2-3

Figure 2.3: Types of entities of wireframe

Based on the above definitions, the definition of entities comprises the topology and geometry. The topology and geometry relationship is shown in Figure

2.4. In the case of wireframe entities, the topology data are edge and point and each topology data is described by their geometry. In the case of topology, the types of edge are the topology, namely; line, circle, arc, etc, whilst the mathematical representation of the edge is its geometrical data.

Figure 2.4: Topology and geometry relationship of wireframe entities

The topology and their geometry must be together in defining the entities.

When topology and geometry is together, it has have its own advantage. When only the topology is used to represent the wireframe entities, two different lines will have the same representation and both of the lines cannot be distinguished. Therefore,

2-4 geometry will make each entity unique. Therefore, topology and geometry together they can

 make each model unique, no two models has the same low-level definition,

 determine the method to build the entities,

 determine the manipulation of the entities, and

 determine the position of the entities in space

2.1.2 Mathematical Representation of the Entities

Every entity in wire frame has the geometry in form of curve. The geometry of the curve is the mathematical equation that governs the curve. This curve representation can be categorized into two: implicit and parametric.

Implicit Representation

Curve is mathematically represented by a function. When the relationship of all the variables is given by an equation, this curve is represented implicitly. Therefore, the implicit representation of curve is as follows

2D curve: f (x, y) = 0

3D curve f (x, y, z) = 0

The implicit representation of wireframe entities are as the follow:

Line: x(y2  y1)  y(x2  x1)  x1(y2  y1)  y1(x2  x1)  0 … (2.1)

Where (x1, y1): start point

(x2, y2): end point

Circle x2  y2  r 2  0 … (2.2)

2-5

Where r: radius of the circle

2 2  x   y  Ellipse      1 … (2.3)  a   b 

Where: a: radius measured along X axis

b: radius measure along Y axis

n i Curve y  ai x … (2.4) i0

Where: ai: coefficient with n+1 control points

Parametric representation

Unlike implicit representation, the parametric representation each variable will be represented using separate mathematic equation. On each variable is controlled by free parameter t and this variable varies from 0 to 1.

2D parametric equation x = x(t), y = y(t)

3D parametric equation x = x(t), y = y(t), z = z(t)

Where t: free parameter

There parametric representation for each entity will as follows:

Line: x(t)  x1  (x2  x1)t

y(t)  y1  (y2  y1)t … (2.5)

Circle x(t)  r cos(2 t)

y(t)  r sin( 2 t) … (2.6)

2-6

Ellipse x(t)  a cos(2 t)

y(t)  b sin( 2 t) … (2.7)

n i Curve x(t)   ai t i0

n i y(t)  ai t … (2.8) i0

Implicit vs. Parametric Curve

The major difference between implicit and parametric curve is that the implicit requires all the variables in a single function, whilst the parametric curve will allow the representation based its variable component.

Therefore, one of the advantages of implementing parametric modeling is that the modeling can be carried out based on the components. If the 2D environment, x and y component equation are involved and this 2D environment can be expanded to

3D environment by adding z component equations. Furthermore, handling the equations by components allows better programming style.

Another advantage of parametric curve relies on the free parameter of the curve. The introduction of free parameter t in parametric equation will have the following advantages: i. Equally spaced vertices: Since the increment of free parameter is set to be equal,

the curve generated will have an equally spaced curve. Figure 2.xa shows the

circle that has been developed using implicit equation which the spacing

2-7

between vertices varies, whilst the equally spaced curve in Figure 2.5 is

generated by implementing the parametric equation.

Figure 2.5: Vertex spacing based on (a) implicit and (b) parametric equation ii. Suitable for component wise problem: Some of engineering problems will be

easier to be solved when the components of equations are treated as

independence. As such the projectile, dynamic of motion will be handled by its

components and the curve produced is parametric curve in function time.

Discussion 2.1

Based on the equation of circle and ellipse and the topology and geometry relationship, discuss where is the information on radius for the circle and the minor and major axis for the ellipse will be stored and why?

Example 2.1

Plot the curve generated using implicit and parametric equation for ellipse that has its center point at (10, 3), the horizontal radius (major radius) of 10 mm, and the vertical radius (minor radius) of 4 mm.

Implicit Equation

2 2  x   y  Equation for ellipse :      1 , where a = 10 and b = 4  a   b 

2-8

2 2  x   y  Therefore      1 10   4 

Based on y axis, the curve will be formed when 10  x 10 and  2  y  2 , therefore, the curve can be created by setting x from -10 to 10 by increment of 0.5.

Using the following, it will yield to two answer of y which y1 and y2.

2  x  y1, y2  2 1   10 

The above equation is based on the center point of ellipse at the origin ( 0,0 ), therefore coordinate of x, y1, and y2 must be translated to the new center point with is

(10, 3).

Therefore, Table 2.1 can be formed.

Table 2.1: Vertices of the ellipse using implicit equations

x y1 y2 x+Xc y1 + Yc y2+ yc -10.00 0.00 0.00 0.00 3.00 3.00 -9.50 0.62 -0.62 0.50 3.62 2.38 -9.00 0.87 -0.87 1.00 3.87 2.13 -8.50 1.05 -1.05 1.50 4.05 1.95 -8.00 1.20 -1.20 2.00 4.20 1.80 -7.50 1.32 -1.32 2.50 4.32 1.68 -7.00 1.43 -1.43 3.00 4.43 1.57 … … … … … … 7.00 1.43 -1.43 17.00 4.43 1.57 7.50 1.32 -1.32 17.50 4.32 1.68 8.00 1.20 -1.20 18.00 4.20 1.80 8.50 1.05 -1.05 18.50 4.05 1.95 9.00 0.87 -0.87 19.00 3.87 2.13 9.50 0.62 -0.62 19.50 3.62 2.38 10.00 0.00 0.00 20.00 3.00 3.00

When x and y1,y2 are plotted, ellipse as in Figure 2.6 are formed.

2-9

Figure 2.6: Ellipse creation using implicit equation

Parametric Equation

Equation 2.7 will create ellipse with its center point at the origin. However, in the center point of the ellipse is at (10, 3) and therefore, equation 2.7 will be transformed into the following equation.

x(t) 10 cos(2 t) 10

y(t)  2sin( 2 t)  3

Table 2.2 shows the calculated values based on the equation.

Table 2.2: Vertices of ellipse using parametric equation

t x y 0 20.00 3.00 0.05 19.51 3.62 0.1 18.09 4.18 0.15 15.87 4.62 0.2 13.09 4.90 0.25 9.99 5.00 0.3 6.90 4.90 … … … 0.7 6.93 1.10 0.75 10.02 1.00 0.8 13.11 1.10 0.85 15.90 1.38 0.9 18.10 1.83 0.95 19.52 2.39 1 20.00 3.00 From Table 2.2, the vertices are plotted and ellipse as shown Figure 2.7 is generated.

2-10

Figure 2.7: Ellipse generated using Parametric Equation

2.1.3 Synthetic curve representation

Synthetic curve has been used widely in many applications such as in the modeling of the body of the car or mechanical part. The synthetic curve can be divided into two types based on how the curve is created using either interpolation or approximation method. Interpolation method will form a curve that will go through the vertices of the curve, whilst the approximation method will create a curve that may not go through the vertices.

Normally curve is constructed by multiple small segment of curves. Therefore, the continuity at the incident vertex of two adjacent curves plays an important role to ensure the smoothness of the curve. The continuity starts from zero order (C0) as shown in Figure 2.8a when the curve is joined without any adjustment of the end vertices. When both curves are set to have the same tangent as shown in Figure 2.8b which is the first derivative, first-order continuity (C1) is created. The second derivative will cause both curves to have same tangent and center of the curvature as shown in Figure 2.8c, second-order continuity is created. The second order continuity curve is called Spline curve.

2-11

Figure 2.8: Curve continuity

2.3.1.1 Interpolation method

The basic interpolation method curve is cubic equation. The following formula is the mathematical representation of the cubic curve.

aP  b  P(t)  t 3 t 2 t 1  P  … (2.9) cP    dP 

where 0 <= t <= 1

Hermite Curve

Hermite Curve is created based on two points. The first point is start point (P0) and the second one is the end point (P1). The start and end point are created when the free parameter is equal to 0 and 1 respectively. Hence, the two conditions are formed.

Condition 1: when free parameter t = 0, start point is created P(0) = P0

aP  b   P  0 0 0 1  X 0 Y0  … (2.9i) cP    dP 

Condition 2: when free parameter t = 1, end point is created P(1) = P1, therefore

2-12

aP  b   P  1 1 1 1  X1 Y1 … (2.9ii) cP    dP 

However, these two conditions will not be able to solve the cubic equation that comprises of four unknowns (ap, bp, cp, and dp). Therefore, the other two known parameter is the tangent of the start and end points. Altogether they can solve all the cubic parameters. The tangent is the first continuity and it is the first derivative of equation 2.9 that will yield to equation 2.10

aP  b  3t 2 2t 1 0  P   P'(t) … (2.10) cP    dP 

Therefore, the tangent of the start point will be when free parameter t = 0 of equation 2.10 and the tangent of the end point will be when free parameter t = 1 of the same equation.

Condition 3: The tangent of the start point when free parameter t = 0, P(0) = P0’

aP  b   P  ' ' 0 0 1 0  X 0 Y0  … (2.10i) cP    dP 

Condition4: The tangent of the end point when free parameter t =1, P’(1) = P1’

aP  b   P  ' ' 3 2 1 0  X1 Y1  … (2.10ii)) cP    dP 

2-13

When all the conditions are represented into one equation, equation 2.11 are formed

0 0 0 1aP  P0 1 1 1 1b   P1   P     … (2.11) 0 0 1 0cp  P0'      3 2 1 0dP  P1'

Therefore, coefficients for Hermite can be solved

1 aP  0 0 0 1 P0 b  1 1 1 1  P1  P       cp  0 0 1 0 P0'       d 3 2 1 0 P1'  P      aP   2  2 1 1 P0 b   3 3  2 1 P1  P      cp   0 0 1 0 P0'      dP   1 0 0 0  P1'

Finally, Hermite curve will be as equation 2.12.

 2  2 1 1  P0  3 3  2 1 P1  P(t)  t3 t 2 t 1   … (2.12)  0 0 1 0 P0'    '   1 0 0 0 P1 

As far as the components is concerned the above matrices is expanded to

 2  2 1 1 x0 y0   3 3  2 1x y  3 2   1 1  P(t)  t t t 1 ' ' … (2.12i)  0 0 1 0 x0 y0    ' '   1 0 0 0 x1 y1 

Example 2.2

Draw Hermite curve if P0(0,0) and P1(1,0) with the following tangent i) P0’(0,1) and P1(0,-1)

2-14 ii) P0’(4,1) and P1’(4,-1),

By inserting the value of coordinates and the tangent of the start and end point into equation 2.12i:

 2  2 1 1 0 0   3 3  2 11 0  x y t 3 t 2 t 1    0 0 1 0 0 1      1 0 0 0 0 1

Iteration process is carried out start with t = 0 until t = 1 with an increment of

0.1, equation 2,12i will give the x and y coordinates as in Table 2.3. When these coordinates are plotted, it will generate Hermite curve as shown in Figure 2.9a.

Table 2.2: Generated vertices for example 2.2i

t x y 0 0 0 0.1 0.028 0.09 0.2 0.104 0.16 0.3 0.216 0.21 0.4 0.352 0.24 0.5 0.5 0.25 0.6 0.648 0.24 0.7 0.784 0.21 0.8 0.896 0.16 0.9 0.972 0.09 1 1 0

Similar approach is carried out on problem ii), as a result the following equation is generated and Table 2.3 shows the vertices. The curve generated is shown in Figure

2.9b.

2-15

 2  2 1 1 0 0   3 3  2 11 0  x y t 3 t 2 t 1    0 0 1 0 4 1      1 0 0 0 4 1

Table 2.3: Generated vertices for problem 2.2ii

t x y 0 0 0 0.1 0.316 0.09 0.2 0.488 0.16 0.3 0.552 0.21 0.4 0.544 0.24 0.5 0.5 0.25 0.6 0.456 0.24 0.7 0.448 0.21 0.8 0.512 0.16 0.9 0.684 0.09 1 1 0

Figure 2.9: Generated Hermite curve

Cubic Spline

Hermite Curve is a curve generated when two point are given. In the case, there are n points (n > 2), n-1 Hermite curve can be drawn. Therefore, when two or more Hermite curve is combined, Cubic Spline is created.

2-16

The continuity of the points must be taken into consideration to ensure the smoothness of the Cubic Spline curve. In the case of Cubic Spline, second order continuity is set at the incident vertex of two adjacent Hermite curves. The first order continuity will set the tangents of two adjacent Hermite curves equal, whilst the second order continuity will ensure the radius of curve of the incident vertex is equal.

Following shows the mathematical equation of the first and second order continuity of equation 2.9.

First order continuity

aP  b  P'(t)  3t 2 2t 1 0  P  … (2.13) cP    dP 

Second order continuity9i-1

aP  b  P"(t)  6t 2 0 0  P  … (2.14) cP    dP 

Figure 2.10 shows the incident vertex of Hermite curve segment (i – 1) meets another

Hermite curve segment (i) and the conditions needs to be complied to ensure the smoothness of the curve. The conditions are

i. The end point of segment (i-1) must be the same start point of segment (i).

Therefore P(i-1)(1) = P(i)(0)

ii. The slope of the end point of segment (i-1) must be equal to the slope of the

start point of segment (i). Therefore P’(i-1)(1) = P’(i)(0)

2-17

iii. The curvature of the end point of segment (i-1) must be equal to the curvature

of the start point of segment (i). Therefore P”(i-1)(1) = P”(i)(0)

Figure 2.10: Conditions for the incident vertex of two curve segments

Based on the condition iii), the following equation can be derived

P”(i-1)(1) = P”(i)(0)

aP(i1)  aP(i)  b  b  6 2 0 0  P(i1)   0 2 0 0 P(i)  cP(i1)  cP(i)      d P(i1)  d P(i) 

 2  2 1 1 P0(i1)   2  2 1 1 P0(i)       3 3  2 1 P1  3 3  2 1 P1 6 2 0 0  (i1)   0 2 0 0  (i)   0 0 1 0 P0'(i1)   0 0 1 0 P0'(i)         1 0 0 0  P1'(i1)   1 0 0 0  P1'(i) 

Refer back to algebraic coefficient of a,b,c and d, the above equation will

6 [2 P0(i-1) – 2P1(i-1) + P0’(i-1) + P1’(i-1)] + 2 [-3P0(i-1) + 3 P1(i-1) – 2 P0’(i-1) – P1’(1-1)] =

2 [-3P0(i) + 3 P1(i) – 2 P0’(i) – P1’(i)]

2-18

Since

P0(i-1) = P(i-1) P0’(i-1) = P’(i-1)

P1(i-1) = Pi P1(i-1) = P’i

P0(i) = Pi P0’(i) = P’i

P1(i) = Pi+1 P1(i) = P’i+1

Simplification of the above equation yields to the following equation

P’(i-1) + 4 Pi’ + P’(i+1) = -3 P(i-1) + 3 P(i+1)

In the case of the cubic spline that comprises of (m+1) points, the equation will be i = 0 unknown

i = 1 P’(0) + 4 P1’ + P’(2) = -3 P(0) + 3 P(2)

i = 2 P’(1) + 4 P2’ + P’(3) = -3 P(0) + 3 P(3)

i = m-1 P’(m-2) + 4 Pm-1’ + P’(m)= -3 P(m-2) + 3 P(m) i = m unknown

These equation will solve the unknown P’(1) to P’(m-1), whilst P’(0) and P’(m) are still unknown. There are two method of determining the P’(0) and P’(m) based on

i. Cubic spline with known P’(0) and P’(m)

The matrix form will be

2-19

' 1 0 0 . . . .  P0   P0    '    1 4 1 0 . . . P 3(P  P )   1   2 0  ' 0 1 4 1 . . .  P   3(P3  P1)    2     ......  .    .  … (2.15i)  . . 0 1 4 1 0P'  3(P  P )  m2  m1 m3   '    . . 0 0 1 4 1Pm1   3(Pm  Pm2 )    '     . . 0 0 0 0 1 Pm   Pm 

Therefore, the solution to vector tangent will be

' 1  P0  1 0 0 . . . .   P0   '      P 1 4 1 0 . . . 3(P  P )  1     2 0  '  P  0 1 4 1 . . .   3(P3  P1)   2       .    ......   .  … (2.15ii) P'   . . 0 1 4 1 0 3(P  P )  m2  m1 m3 '     Pm1   . . 0 0 1 4 1  3(Pm  Pm2 )   '       Pm   . . 0 0 0 0 1  Pm 

ii. Natural Cubic Splines in which the second derivatives of the P”0 and P”m are

set to zero (0)

Recall equation for the second derivative of the Hermite Curve is

aP  b  P"(t)  6t 2 0 0  P  cP    dP 

When P”0(0) = 0

2 bP(0) = 0

bP(0) = 0

Recall Hermite curve equation

2-20

aP   2  2 1 1 P0 b   3 3  2 1 P1  P      cp   0 0 1 0 P0'      dP   1 0 0 0  P1'

Therefore, when bp = 0

-3P0 + 3 P1 – 2 P0’ – P1’ = 0

i = 0 2P0’+ P1’ = 3 (P1 – P0)

When P”m(1) = 0

6 aP(m) + 2 bP(m) = 0

3 aP(m) + bP(m) = 0

When ap(m) and bp(m) are inserted, the equation will be expanded to

6 P(m-1) – 6Pm + 3P(m-1)’ + 3Pm’ - 3P(m-1) + 3 Pm – 2 P(m-1)’ – Pm’ = 0

i = m P(m-1)’+ 2Pm’ = 3(Pm – Pm-1)

Therefore, the final equation will be

' 2 1 0 . . . .  P0   3(P1  P0 )    '    1 4 1 0 . . . P 3(P  P )   1   2 0  ' 0 1 4 1 . . .  P   3(P3  P1)    2     ......  .    .   . . 0 1 4 1 0P'  3(P  P )  m2  m1 m3   '    . . 0 0 1 4 1Pm1   3(Pm  Pm2 )    '     . . 0 0 0 1 2 Pm   3(Pm  Pm1) 

The vector tangent of each vertices will be

2-21

' 1  P0  2 1 0 . . . .   3(P1  P0 )   '      P 1 4 1 0 . . . 3(P  P )  1     2 0  '  P  0 1 4 1 . . .   3(P3  P1)   2       .    ......   .  P'   . . 0 1 4 1 0 3(P  P )  m2  m1 m3 '     Pm1   . . 0 0 1 4 1  3(Pm  Pm2 )   '       Pm   . . 0 0 0 1 2  3(Pm  Pm1) 

Example 2.3

Given four points, P0 (0,0), P1(2,1), P3(4,4), and P3(6,0).

Calculate the tangent vector for each vertex based on i) known tangent vector of P0’(1,1) and P3’(-1,1) and ii) natural cubic splines using both methods. Based on the tangent vector, draw

the curve. i) Known tangent vector using recursive method.

' 1 ' P0  1 0 0 0  P0   '      P 1 4 1 0 3(P  P )  1      2 0   '    P2 0 1 4 1 3(P3  P1)  '     '  P3  0 0 0 1  P3 

When the component is included in the matrix form

' 1 ' ' P0  1 0 0 0  P0x P0y   '      P 1 4 1 0 3(P2  P0 ) 3(P2  P0 )  1      x x y y   '    P2 0 1 4 1 3(P3x  P1x ) 3(P3Y  P1y )  '     ' '  P3  0 0 0 1  P3x P3x 

2-22

' 1 P0  1 0 0 0  1 1   '      P 1 4 1 0 3(4  0) 3(4  0)  1        '  P2 0 1 4 1 3(6  2) 3(0 1)  '      P3  0 0 0 1  1 1 

' P0   1 0 0 0  1 1   '     P  0.267 0.267  0.067 0.067 12 12  1       '  P2  0.067  0.067 0.267  0.26712  3  '     P3   0 0 0 1 1 1 

' P0   1 1   '    P 2.067 3.2  1      '  P2 2.733 1.8  '    P3   1 1 

Since there are four vertices, there will three (n-1) Hermite Curve. The properties of the Hermite will be as follows

1st curve: P0 (0, 0) , P1 (2,1), P0’(1,1), P1’(2.067, 3.2)

2nd curve: P1 (2, 1) , P2 (4,4), P1’(2.067, 3.2), P2’(2.733, -1.8)

3rd curve: P1 (4, 4) , P2 (6,0), P1’(2.733, -1.8), P2’(-1, 1)

The Cubic spline is shown in Figure 2.11

Figure 2.11: Cubic Spline with known P0’ and P3’

2-23 ii) Natural Cubic Spline

Insert all the parameter into the Natural Cubic Spline eqautions

' 1 P0  2 1 0 0 3(P1  P0 )  '      P 1 4 1 0 3(P  P )  1      2 0   '  P2 0 1 4 1 3(P3  P1)  '      P3  0 0 1 2 3(P3  P2 )

Expanding the equation its x and y coordinates

' 1 P0  2 1 0 0 3(P1x  P0x ) 3(P1y  P0y )  '      P 1 4 1 0 3(P2  P0 ) 3(P2  P0 )  1     x x y y  '  P  0 1 4 1 3(P3x  P1x ) 3(P3y  P1y )   2      ' 3(P3  P2 ) 3(P3  P2 ) P3  0 0 1 2  x x y y 

Inserting P1, P2, P3, and P4 into the equations

' 1 P0  2 1 0 0 3(2  0) 3(1 0)  '      P 1 4 1 0 3(4  0) 3(4  0)  1        '  P2 0 1 4 1 3(6  2) 3(0 1)  '      P3  0 0 1 2 3(6  4) 3(0  4)

Calculating the tangent of vertices for all the vertices

' 1 P0  2 1 0 0 3(2  0) 3(1 0)  '      P 1 4 1 0 3(4  0) 3(4  0)  1        '  P2 0 1 4 1 3(6  2) 3(0 1)  '      P3  0 0 1 2 3(6  4) 3(0  4)

' P0   0.578  0.156 0.044  0.022 6 3   '     P  0.156 0.311  0.089 0.044 12 12  1       '  P2  0.044  0.089 0.311  0.15612  3   '     P3   0.022 0.044  0.156 0.578  6 12

2-24

' P0   2.156  0.1444  '    P 1.689 3.889  1      '  P2  3.089  2.111   '    P3   2.044 1.556 

Since there are four vertices, there are three Hermite segments will the following conditions

1st curve: P0 (0, 0), P1 (2, 1), P0’ (2.156, -0.1444), P1’ (1.689, 3.889)

2nd curve: P1 (2, 1), P2 (4, 4), P1’ (1.689, 3.889), P2’ (3.089, -2.111)

3rd curve: P1 (4, 4), P2 (6, 0), P1’ (3.089, -2.111), P2’ (2.044, 1.556)

The Cubic spline is shown in Figure 2.12

Figure 2.12: Natural cubic spline

2.3.2 Approximation method

The second method of curve generation is approximation method. Unlike the Hermite and Cubic Spline, the curve will go through all the points. However, in approximation method, the points are used to control the curve and the curve may not go through the point.

2-25

The foundation of curve generation is the curve is generated from the blending function of the control points. The foundation equation for approximation method will be

n P(t)   Pi Bi (t) i0 … (2.16)

 P0B0  P1B1 ... Pi Bi

Where: Pi: point i

Bi: blending function for Pi

This blending function must satisfy the condition that the summation of the blending function is equal to 1.

Bi (t)  0 for all i 0  t 1 … (2.17) n B (t) 1 0  t 1 i0 i

Two most famous approximation method curve is Bezier and B-Spline that will be discuss in the following.

Bezier

Bezier curve is defined by two endpoints and the control points. The control points will control the tangent vector of the endpoints. Therefore, four points are the least minimum, which the start and the end point will be the two endpoints. The second and third points are used to control the gradient of the curve.

The blending function is

n! B  (t)i (1 t)n1 0  t  1 i,n i!(n 1)! … (2.18) i  0,1,..., n

2-26

When the basic Bezier equation is expanded on four vertices, the equation will be

n P(t)   Pi Bi,n (t) i0 … (2.19)

 P0 B0,3  P1B1,3  P2 B2,3  P3B3,3

The blending function will be

3! B  t 0 (1 t)3  (1 t)3 0,3 0!3!

3! B  t1 (1 t)2  3t(1 t)2 1,3 1!2!

3! B  t 2 (1 t)1  3t 2 (1 t) 2,3 2!1!

3! B  t 3 (1 t)0  t 3 3,3 3!0!

When the blending functions are inserted to the equation, the equation becomes

3 2 2 3 P(t)  (1 t) P0  3t(1 t) P1  3t (1 t)P2  t P3

Expanding the equation,

2 3 2 3 2 3 3 P(t)  (13t  3t t )P0  (3t  6t  3t )P1  (3t 3t )P2  t P3

Based on the above, the matrix representation will be

1 3  3 1P0   3  6 3 0 P  P(t)  [t 3 t 2 t 1]  1  … (2.20i)  3 3 0 0 P2      1 0 0 0 P3 

2-27

1 3 3 1P0x P0 y     3  6 3 0 P P P(t)  [t 3 t 2 t 1]  1x 1y  …(2.20ii) 3 3 0 0P2x P2 y      1 0 0 0P3x P2 y 

Example 2.4

Given four points, P0 (0,0), P1(2,1), P3(4,4), and P3(6,0). Draw the generated Bezier

Curve.

Using the free parameter from 0 to 1 by increment of 0.1, the coordinates of each vertices can be calculated as shown in Figure 2.4

Table 2.4: The vertices of the Bezier Curve

t Xp YP 0 0 0 0.1 0.6 0.351 0.2 1.2 0.768 0.3 1.8 1.197 0.4 2.4 1.584 0.5 3 1.875 0.6 3.6 2.016 0.7 4.2 1.953 0.8 4.8 1.632 0.9 5.4 0.999 1 6 0

When the vertices are plotted, Bezier curve as shown in Figure 2.13 is generated.

2-28

Figure 2.13: Generated Bezier curve

Note

As mention previously, the P1 and P2 will control the tangent of the P0. This is shown in Figure 2.14. By moving P1 at two different position will result in two different curves.

( a ) ( b )

Figure 2.14: Variation of tangent between P0 and P1

B-Spline

Similar to Bezier Curve, B-Spline is controlled by its blending function. In the case of

B-Spline that is created by four points, equation 2.21 can be used

2-29

Pi (t)  B0,4 (t)P0  B1,4 (t)P1  B2,4 (t)P2  B3,4 (t)P3 … (2.21)

The development of the blending function with four vertices comprises is shown in the following. Figure 2.15 to 2.18 shows illustrates the blending graphically and their mathematical representations are shown eq 2.22i to 2.22iv respectively.

Figure 2.15: Blending function B0,4

t  33  3  t  2  1  3t 3 15t 2  21t  5  2  t  1 B (t)  … (2.22i) 0,4  3 2 6  3t  3t  3t 1 1 t  0  3  1 t 0  t 1

Figure 2.16: Blending function B1,4

 t  23  2  t  1  1  3(t 1)3 15(t 1)2  21(t 1)  5 1 t  0 B (t)  … (2.22ii) 1,4  3 2 6  3(t 1)  3(t 1)  3(t 1) 1 0  t 1  3  t 1 t  2

2-30

Figure 2.17: Blending function B2,4

 t 13 1 t  0  1  3(t  2)3 15(t  2)2  21(t  2)  5 0  t 1 B (t)  …(2.22iii) 2,4  3 2 6  3(t  2)  3(t  2)  3(t  2) 1 1 t  2  3  t 1 2  t  3

Figure 2.18: Blending function B3,4

 t3 0  t 1  1  3(t  3)3 15(t  3)2  21(t  3)  5 1 t  2 B (t)  … (2.22iv) 3,4  3 2 6  3(t  3)  3(t  3)  3(t  3) 1 2  t  3  3  t  2 3  t  4

When the functions are combined and the range of t is set from 0 to 1, the blending function is shown in Figure 2.19.

2-31

Figure 2.19: Blending function 0  t  1

Refering to eq 2.21 and equation 2,22i to 2.22iv, equation 2.23i and 2.23ii are generated.

1 P(t)   P 1 3t  3t 2  t 3  P 4  6t 2  3t 3  P 1 3t  3t 2  3t 3  P t 3  6 0 1 2 3

… (2.23i)

1 P(t)  (P  3P  3P  P )t 3  (3P  6P  3P )t 2  (3P  3P )t  (P  4P  P ) 6 0 1 2 3 0 1 2 0 2 0 1 2

… (2.23ii)

Equation 2.23ii can be represented into eq 2.24.

1 3 3 1P0     1 3  6 3 0 P P(t)  [t 3 t 2 t 1]   1  … 2.24 6 3 0 3 0P2      1 4 1 0P3 

2-32

Example 2.5

Draw the B-Spline curve based on P0 (0,0), P1 (2, 1), P2 (4, 4), and P3(6, 0)

Using iteration of t, from 0 to 1 by increment of 0.1, vertices can be calculated using equation 2.24 which is shown in Table 2.5.

Table 2.5: Vertices for B-Spline curve

t X Y 0 2 1.33 0.1 2.2 1.54 0.2 2.4 1.76 0.3 2.6 1.98 0.4 2.8 2.20 0.5 3 2.40 0.6 3.2 2.57 0.7 3.4 2.71 0.8 3.6 2.81 0.9 3.8 2.85 1 4 2.83

When these vertices are plotted, curve as shown in Figure 2.20 is generated.

Figure 2.20: The generated B-Spline curve

Note:

2-33

Point P1 and P2 will control the tangent of the curve. Therefore, by positioning P1 at two different positions as shown in Figure 2.21 will generate two different curves.

This is because P1 and P2 will set the tangent of the start and end point of the B-

Spline curve.

( a ) ( b )

Figure 2.21: Curve generated from two different positions of P1

Furthermore, the generated B-Spline generated by point P0-P1-P2-P3 will not start and end at P0 and P3. Therefore, to create B-Spline curve that will go through P0 and

P3, two additional points are needed. The first additional point is point P-1 which is positioned before P0. The second additional point is point P4 that is positioned after

P3. The conditions of the additional point are

i) the additional point must create straight line with P0 and P1 for P-1

and P2 and P3 for point P4

ii) Length of P-1 P0 must equal to P0P1 and P3P4 must equal P2P3.

With these conditions, P-1 and P4 will be (-2, -4) and (8, -4).

To create the first segment of B-Spline curve, B-Spline is generated by four points P-

1, P0, P1, and P2, whilst the third segment are created by point P1-P2-P3-P4. As a

2-34 result, three segments of B-Spline curve are created that starts at P0 and ends at P3 as shown in Figure 2.22.

Figure 2.22: B-Spline curve starts from P0 and ends at P3

2.3.3 Disadvantages of wire frame

Wireframe has its own disadvantages. The disadvantages are i. Multiple interpretations: Figure 2.23a shows one wireframe which can be

translated into various shape. ii. Ambiguous model: Some of the model can be created which is in fact unreal

object as shown in Figure 2.23b. iii. Unreal entities: Wireframe representation fails to model curve object. For

example, one entity is introduced to represent the curve cylindrical face as

shown in Figure 2.23c.

2-35

Figure 2.23: Disadvantages of wireframe representation. iv. Each entity is stored independently: the data on the entities are stored

independently based on the entity. As such if n entities in the model wireframe,

n data are required to have and have been treated as individual entity without

the connectivity properties.

2.4 SURFACE

Surface is the extension of the wire frame. The basic equation for surface is based on parametric straight line that is connected by P1 and P2. The coordinates when free parameter u can be calculated using equation 2.25

P1  Q(u)  (1u) u  … (2.25) P2 

Where: u : free parameter 0  u1

2.4.1 Billinear Surface

Billinear surface is a surface that is formed from four vertices using linear interpolation. Figure 2.24 shows the bilinear surface that is created.

2-36

Figure 2.24: Billinear Surface

P(0,0)  P(1,0) Q(u, w)  (1 u)(1 w) u(1 w) (1 u)w uw   … (2.26)  P(0,1)    P(1,1) 

Where u, w: free parameter 0  u1 and 0  w1

Example 2.6

Draw the vertices for every 0.2 free parameter increment of the bilinear surface that is constructed by the following four vertices

(a) P0 (0, 0), P1 (10, 0), P2 (10, 8), and P3 (0, 8)

Prior to inserting, the corresponding vertices must be matched vector defined in the formula.

P(0, 0) = P0 (0, 0)

P(1, 0) = P1 (10, 0)

P(0, 1) = P3 (0, 8)

2-37

P(1, 1) = P2 (10, 8)

 0 0 10 0 Q(u, w)  (1 u)(1 w) u(1 w) (1 u)w uw    0 8   10 8

To calculate the vertices, double iterative is done on the free parameter. For every iteration of free parameter u must have a complete iteration from 0 to 1 of free parameter w. To demonstrate the iteration process, refer to the first and second column of Table 2.6. For every iteration of u and w, equation 2.6 will calculate each vertices and as a result, Table 2.6 shows the example vertices on the Billinear surface and Figure 2.25a shows the vertices on the Billinear surface

Table 2.6: Vertices on the bilinear surface

u w X Y 0 0 0 0 0.2 0 1.6 0.4 0 3.2 0.6 0 4.8 0.8 0 6.4 1 0 8 0.2 0 2 0 0.2 2 1.6 0.4 2 3.2 0.6 2 4.8 … … … … … … … … 1 0.2 10 1.6 0.4 10 3.2 0.6 10 4.8 0.8 10 6.4 1 10 8

( b ) P0(0,0), P1 (8.6603, 5), P2 (13.6603, 13.6603), and P4 (5, 8.6603)

2-38

Similar step as done in (a) is carried out here. Therefore, the corresponding vertices will be

P(0, 0) = P0 (0, 0)

P(1, 0) = P1 (8.6603, 5)

P(0, 1) = P3 (5, 8.6603)

P(1, 1) = P2 (13.6603, 13.6603)

 0 0   8.6603 5  Q(u, w)  (1 u)(1 w) u(1 w) (1 u)w uw    5 8.6603    13.6603 13.6603

Table 2.7 shows examples of the calculated vertices and Figure 2.25b shows the resulted Billinear surface.

Table 2.7: Vertices on the bilinear surface

u w XP YP 0 0 0 0 0.2 1 1.73206 0.4 2 3.46412 0.6 3 5.19618 0.8 4 6.92824 1 5 8.6603 0.2 0 1.73206 1 0.2 2.73206 2.73206 … … … … … … … … 1 0 8.6603 5 0.2 9.6603 6.73206 0.4 10.6603 8.46412 0.6 11.6603 10.19618 0.8 12.6603 11.92824 1 13.6603 13.6603

2-39

( a ) ( b )

Figure 2.25: Billinear surfaces

( c ) P0 (0, 0,0), P1 (10, 0,0), P2 (10, 8,10), and P3 (0, 8,8)

Similar step as done in (a) is carried out here. Therefore, the corresponding vertices will be

P(0, 0) = P0 (0, 0, 0)

P(1, 0) = P1 (10, 0, 0)

P(0, 1) = P3 (0, 8, 8)

P(1, 1) = P2 (10, 8, 10)

 0 0 0  10 0 0  Q(u, w)  (1 u)(1 w) u(1 w) (1 u)w uw   10 8 10    0 8 8 

This will produce 122 points as some of the points are shown in Table 2.8.

Table 2.8: Points for 3D bilinear surface

x y z 0 0 0 1 0 0 2 0 0

2-40

3 0 0 4 0 0 5 0 0 6 0 0 7 0 0 8 0 0 9 0 0 10 0 0 0 0.8 1 1 0.8 0.98 … … … … … … 10 7.2 7.2 0 8 10 1 8 9.8 2 8 9.6 3 8 9.4 4 8 9.2 5 8 9 6 8 8.8 7 8 8.6 8 8 8.4 9 8 8.2 10 8 8 Plotting the vertices into surface will produce surface plot as in Figure 2.26a and the point point as in Figure 2.26b.

Figure 2.26: 3D Billinear surface (a) Surface and (b) Point plot

2.4.2 Tabulated Surface

Tabulated surface is created when a curve is translated along a plane that is perpendicular to plane of the curve. The curve is created on XY plane and then it will

2-41 translated along Z axis. When curve on plane XY is extended from P(u, u, 0), w = 0 and u from 0 to 1 to P2(u, u, 1) w = 1 and u from 0 to 1, tabulated surface is generated. Example of tabulated surface is shown in Figure 2.26 and equation 2.27 is the mathematical formula to create the tabulated surface.

Figure 2.27: Tabulated surfaces

P1(u,u,0) Q(u,u,w)  (1 w) w  … (2.27) P2(u,u,1)

where u, w is free parameter 0  w1 and 0  u1

Example 2.7

Generate the vertices that forms a cylindrical surface that is generated by circle with radius 10 on XY plane and then the circle is along axis that is formed from P0(0 ,0 ,0) to P1 (0, 0, 100).

Solution

The foundation of the tabulated surface is the surface is formed by extruding the curve along predefined axis. Therefore, firstly the curve must be drawn first and then follow with the extrusion process.

2-42

Based on equation 2.28, to generate the tabulated surface, curve can be generated by using parametric equation 2.6 to draw circle with free parameter u from 0 to 1

Circle x(u, w) 10 cos(2 u)

y(u, w) 10 sin( 2 u)

 0  z(u, w)  (1 w) w   100

Similarly, the above equations can be integrated into a single equation 2.27.

10cos(2u) 10sin( 2u) 0  Q(u,u, w)  (1 w) w   10cos(2u) 10sin( 2u) 100

Table 2.8 shows the samples of vertices of the tabulated circle and Figure 2.28 shows the surface and point plot.

Table 2.8: Vertices of the cylindrical surfaces

u xp yp w zp 0 10.00 0.00 0 0 0.1 8.09 5.88 0 0.2 3.09 9.51 0 0.3 -3.10 9.51 0 0.4 -8.10 5.87 0 0.5 -10.00 -0.01 0 0.6 -8.08 -5.89 0 0.7 -3.07 -9.52 0 0.8 3.11 -9.50 0 0.9 8.10 -5.86 0 1 10.00 0.03 0 0 10.00 0.00 0.2 20 0.1 8.09 5.88 20 … … … … … … … … … … 0 10.00 0.00 1 100 0.1 8.09 5.88 100 0.2 3.09 9.51 100

2-43

0.3 -3.10 9.51 100 0.4 -8.10 5.87 100 0.5 -10.00 -0.01 100 0.6 -8.08 -5.89 100 0.7 -3.07 -9.52 100 0.8 3.11 -9.50 100 0.9 8.10 -5.86 100 1 10.00 0.03 100

Figure 2.28: Generated Cylindrical Surfaces (a) Surface and (b) Point plot

2.4.3 Revolved surface

When a curve is revolved along an axis, a revolved surface is created. Revolved surface can be created by revolving a curve along three possible axis, X, Y, and Z axis.

In the case of the revolution along X axis, the curve can be drawn XY and ZX plane.

Equation 2.27i and 2.27ii are the equations that govern the curve generation based on the revolution of X axis on plane XY and ZX plane respectively.

1 0 0 0 0 cos(2w) sin( 2w) 0 Q(u, w)  x(u) y(u) 0 1  … (2.27i) 0  sin( 2w) cos(2w) 0   0 0 0 1

2-44

1 0 0 0 0 cos(2w) sin( 2w) 0 Q(u, w)  x(u) 0 z(u) 1  … (2.27ii) 0  sin( 2w) cos(2w) 0   0 0 0 1

The second axis of revolution is along Y axis and therefore, the curve can be drawn on XY and YZ plane. Equation 2.28i and ii will govern the generation of a revolved surface on XY and YZ plane respectively.

cos(2w) 0  sin( 2w) 0  0 1 0 0 Q(u,w)  x(u) y(u) 0 1  … (2.28i) sin( 2w) 0 cos(2w) 0    0 0 0 1

cos(2w) 0  sin( 2w) 0  0 1 0 0 Q(u, w)  0 y(u) z(u) 1  … (2.28ii) sin( 2w) 0 cos(2w) 0    0 0 0 1

Lastly, the axis of revolution is Z axis and the curve can be drawn on YZ and ZX plane. Equation 2.29i and ii will govern the revolved surface from the respective plane when it is rotated on Z axis.

cos sin  0 0 sin  cos 0 0 Q(u, w)  0 y(u) z(u) 1  … (2.29i)  0 0 1 0    0 0 0 1

cos sin  0 0 sin  cos 0 0 Q(u, w)  z(u) 0 z(u) 1  … (2.29ii)  0 0 1 0    0 0 0 1

2-45

Figure 2.29: Revolved surface

Example 2.8 a) Generate the vertices on the toroidal surface. The toroidal surface is generated

by drawing a circle with 5 radius at center point (20, 0, 0). Then this circle is

rotated about Y axis.

cos(2w) 0  sin( 2w) 0  0 1 0 0 Q(u, w)  5cos(2u)  20 5sin( 2u) 0 1  sin( 2w) 0 cos(2w) 0    0 0 0 1

Table 2.9: Vertices of the cylindrical surfaces

u x(u) y(u) z w x(p) y(p) z(p) 0.0 25.00 0.00 0.00 0.00 25.00 0.00 0.00 0.10 20.22 0.00 -14.70 0.20 7.71 0.00 -23.78 0.30 -7.74 0.00 -23.77 0.40 -20.24 0.00 -14.67 0.50 -25.00 0.00 0.03 0.60 -20.20 0.00 14.73 0.70 -7.68 0.00 23.79 0.80 7.77 0.00 23.76 0.90 20.26 0.00 14.65 1.00 25.00 0.00 -0.06 0.1 24.04 2.94 0.00 0.00 24.04 2.94 0.00

2-46

0.10 19.45 2.94 -14.14 0.20 7.42 2.94 -22.87 … … … … … … … … … … … … … … … … 1.0 25.00 0.00 0.00 0.00 25.00 0.00 0.00 0.10 20.22 0.00 -14.70 0.20 7.71 0.00 -23.78 0.30 -7.74 0.00 -23.77 0.40 -20.24 0.00 -14.67 0.50 -25.00 0.00 0.03 0.60 -20.20 0.00 14.73 0.70 -7.68 0.00 23.79 0.80 7.77 0.00 23.76 0.90 20.26 0.00 14.65 1.00 25.00 0.00 0.00

Figure 2.28: Generated Toroidal Surfaces b) A Hermite with P0 (30, 100), P1 (100, 30), P0’(0, -100), and P1’(100, 0) is

revolved along Y axis to generate a revolved surface.

2-47

 2  2 1 1  30 100 0cos(2w) 0  sin( 2w) 0  3 3  2 1100 30 0 0 1 0 0 Q(u, w)  u3 u 2 u 1     0 0 1 0  0 100 0sin( 2w) 0 cos(2w) 0      1 0 0 0 100 0 0 0 0 0 1 Based on the above equation, samples of vertices generated is shown in Table 2.10.

Figure 2.29 shows the surface and point plot generated from the equations.

Table 2.10: Vertices on the generated revolved surface

u x(u) y(u) z w x(p) y(p) z(p) 0.00 25.00 0.00 0.00 0.00 25.00 0.00 0.00 0.10 20.22 0.00 -14.70 0.20 7.71 0.00 -23.78 0.30 -7.74 0.00 -23.77 0.40 -20.24 0.00 -14.67 0.50 -25.00 0.00 0.03 0.60 -20.20 0.00 14.73 0.70 -7.68 0.00 23.79 0.80 7.77 0.00 23.76 0.90 20.26 0.00 14.65 0.00 0.00 1.00 25.00 0.00 -0.06 0.10 24.04 2.94 0.00 0.00 24.04 2.94 0.00 0.10 19.45 2.94 -14.14 0.20 7.42 2.94 -22.87 … … … … … … … … … … … … … … … … 1.00 25.00 0.01 0.00 0.00 25.00 0.01 0.00 0.10 20.22 0.01 -14.70 0.20 7.71 0.01 -23.78 0.30 -7.74 0.01 -23.77 0.40 -20.24 0.01 -14.67 0.50 -25.00 0.01 0.03 0.60 -20.20 0.01 14.73 0.70 -7.68 0.01 23.79 0.80 7.77 0.01 23.76 0.90 20.26 0.01 14.65 1.00 25.00 0.01 -0.06

2-48

Figure 2.29: Revolved surface of Hermite Curve

2.4.4 Coons Surface

Another surface is called coons surface. Coons surface is generated by four edges that create the boundary of the surface. Equation will govern the coons surface generation

 P(u,0)   P(u,1)  Q(u,w)  (1 w) w (1 u) u  … (2.30) P(0,w)    P(1,w)

When equation is expanded when u,v = 0 and 1, it will yield to

Q(0,0) = 2 P(0,0) Q(1,0) = 2 P(1,0)

Q(1,0) = 2 P (1,0) Q (1,1) = 2 P (1,1)

This shows eq (2.30) will create surface based linear interpolation of bounded edged and another surface created based linear interpolation of points. Therefore, bilinear

2-49 surface based on four points should be deducted from eq (2.31) to create proper equation for coons surface

 P(u,0)   P(u,1)  Q(u, w)  (1 w) w (1 u) u  P(0, w)    P(1, w) … (2.31) P(0,0)  P(1,0)  (1 u)(1 w) u(1 w) (1 u)w uw   P(0,1)    P(1,1) 

Samples of coons surface are shown in Figure 2.30.

Figure 2.30: Sample of coons surface

Example 2.9

Generate the coons surface that is formed by four edges. The u direction is formed by two Hermite curves with the following boundary condition

Table 2.12:

2-50

Figure 2.31: Coon surface created by

2.5 Approximation Curve Surface

Another surface is created by approximation curve surface such Bezier Surface, B-

Spline, and NURBS surface.

The basic equation of

n m Q(u,w)  B (u)B (w)P … (2.32) i0 j0 i,k j,k i, j

Equation 2.32 can also be represented in matrix form

2-51

w3    w2 Q(u,w)  u3 u2 u 1M P M T   … (2.33) curve i. j curve  w     1 

Where: [Mcurve] is matrix representation for the curve

In the following, it will discuss the formation of Bezier and B-Spline surface,

Bezier Surface

Equation 2.18 and 2.20 show the blending function and its matrix representation respectively. Based on these equations, equation 2.34 and 2.35 can be used to generate Bezier surface.

n m n! n! Q(u,w)  (u)i (1u)n1 (w) j (1 w)n1(w)P … (2.34) i0  j0 i!(n 1)! j!(n 1)! i, j

1 3  3 1P0,0 P0,1 P0,2 P0,3     3  6 3 0 P P P P Q(u, w)  u3 u 2 u 1  1,0 1,1 1,2 1,3   3 3 0 0P2,0 P2,1 P2,2 P2,3      1 0 0 0P3,0 P3,1 P3,2 P3,3 

T 1 3  3 1   3  6 3 0 T   w3 w2 w 1 … (2.35)  3 3 0 0    1 0 0 0

Based on the equation, it requires 16 points to create one patch pf Bezier surface

Example 2.10

Create the Bezier surface using the 16 vertices as shown in Figure 2.32

2-52

Figure 2.32: 16 vertices

Solution

In the generation of Bezier surface, equation 2.35 is used. Equation 2.356 can be further developed into three based on the X, Y, and Z coordinates. Following shows the developed equations.

 0 0 0 0   25 25 25 25  x(u,w)  u3 u2 u 1M  M T [w3 w2 w 1]T bezier  75 75 75 75  bezier   100 100 100 100  0 0 0 0  25 25 25 25 y(u,w)  u3 u2 u 1M  M T [w3 w2 w 1]T bezier 25 25 25 25 bezier    0 0 0 0  0 25 50 75 0 25 50 75 z(u,w)  u3 u2 u 1M  M T [w3 w2 w 1]T bezier 0 25 50 75 bezier   0 25 50 75

2-53

Based on these equations, vertices for each iteration of u and w free parameter can be calculated. Examples of the vertices that form the Bezier surface are shown in Table

2.13.

Table 2.13: Example of vertices to form the Bezier surface

u w x y z 0 0 0 0 0 0.1 8.2 6.75 0 0.2 17.6 12 0 0.3 27.9 15.75 0 0.4 38.8 18 0 0.5 50 18.75 0 0.6 61.2 18 0 0.7 72.1 15.75 0 0.8 82.4 12 0 0.9 91.8 6.75 0 1 100 0 0 0 0.1 0 0 7.5 0.1 8.2 6.75 7.5 0.2 17.6 12 7.5 … … … … … … … … … … 0.8 1 82.4 12 75 0.9 91.8 6.75 75 1 100 0 75

These vertices are then plotted into vertex and surface plot as shown in Figure 2.33a and 2.33b respectively.

2-54

( a ) ( b )

Figure 2.33: Bezier Surface created by 16 vertices

B-Spline Surface

Similarly, by inserting matrix for B-Spline into equation 2.33, equation 2.36 is developed to generate B-Spline surface from four vertex B-Spline curve.

1 3  3 1P0,0 P0,1 P0,2 P0,3     1 3  6 3 0 P P P P Q(u, w)  [u3 u2 u 1]   1,0 1,1 1,2 1,3  6  3 0 3 0P2,0 P2,1 P2,2 P2,3      1 4 1 0P3,0 P3,1 P3,2 P3,3 

T 1 3  3 1   1 3  6 3 0   [w3 w2 w 1]T … (2.36) 6  3 0 3 0    1 4 1 0

Example 2.12

Using the vertices shown in Figure 2.32, create the B-Spline surface.

Solution

Equation 2.36 can be further developed based on X, Y and Z coordinates as in the following.

2-55

 0 0 0 0   25 25 25 25  x(u, w)  u3 u2 u 1M  M T [w3 w2 w 1]T BSpline  75 75 75 75  BSpline   100 100 100 100  0 0 0 0  25 25 25 25 y(u, w)  u3 u2 u 1M  M T [w3 w2 w 1]T BSpline 25 25 25 25 BSpline    0 0 0 0  0 25 50 75 0 25 50 75 z(u, w)  u3 u2 u 1M  M T [w3 w2 w 1]T BSpline 0 25 50 75 BSpline   0 25 50 75

Using iteration of the free parameter u and w, coordinates of the vertices on the B-

Spline can be developed. Examples of the vertices are shown in Table 2.14.

Table 2.14: Example of vertices to form the B-Spline surface

u w x y z 0 0 29.17 20.83 25 0.1 33.03 21.96 25 0.2 37.10 22.83 25 0.3 41.32 23.46 25 0.4 45.63 23.83 25 0.5 50.00 23.96 25 0.6 54.37 23.83 25 0.7 58.68 23.46 25 0.8 62.90 22.83 25 0.9 66.97 21.96 25 1 70.83 20.83 25 0 0.1 29.17 20.83 27.5 0.1 33.03 21.96 27.5 … … … … … … … … … … 0.8 1 62.90 22.83 50 0.9 66.97 21.96 50 1 70.83 20.83 50

2-56

When these vertices are plotted, the B-Spline is generated as shown in Figure 2.34a and 2.34b for point and surface plot respectively. Take note that the B-Spline surface does not connected to any of the points on the boundary curve and this is because the nature of B-Spline curve.

( a ) ( b )

Figure 2.34: B-Spline surface created by 16 vertices

2.3 SOLID GEOMETRIC MODELLING

The third type representation is solid geometry. This representation will regard the model as solid and therefore, certain criteria must be fulfilled to be considered as solid. The criteria are as the following:

1) Boundary: The model must have boundary which will be the limit and contain

the interior.

2) Homogenous 3D: The model must not have any dangling edges. The edges

must ensure the boundary and will always in contact with the interior

3) Finite: The model must have finite size and can be described by a limited

amount of information.

2-57

With the above criteria to be fulfilled by solid modeler, all the shortcomings posed by the wireframe and surface can be overcome.

In the following, it discusses the types of solid modeler based on the development of the solid modeler.

2.3.1 Primitive Objects/Instances

Among the earliest solid representation is primitive object representation which the solid is represented by basic body such as box, cylinder, cone, torus, and sphere.

Samples of the basic bodies are shown in Figure 2.35. Therefore, the solid model will be built based on these bodies. The geometrical properties will depend on the type of primitive body, as such one reference point, width, height, and width are the parameters required to build box.

Figure 2.35: Primitive Bodies/Instances

2.3.2 Extrude and revolved bodies

In addition to primitive bodies, solid can also be created based on 2D profile.

When the 2D profile is extruded along the normal of the profile plane, extrude body is created. In addition to extrusion of a profile to create solid model, the profile can also

2-58 be revolved along axis of rotation to create a revolved body. Extrude and revolved body is shown in Figure 2.36.

Figure 2.36: extrude and revolved body

Since extrude and revolved body are created from 2D profile, only the closed profiles can create the solid. Some of the profiles such as in the following will cause failure in solid creation. i. Open profile: Solid cannot be created when the profile is an open profile. On

most modeller, extrusion or revolve of an open profile will create surface

model. This is because the extrusion of curve in the case is profile will create a

surface based the mathematics of surfaces. ii. Nested inner loop: Inner loop is another closed loop that is inside the 2D

profile. The presence of inner loop shows the presence of void in the final

solid model. However, in most solid modellers, they only allows only one

hierarchy inner loop. In case of inner loop inside another inner loop, it is not

allowed.

Figure 2.37 shows profiles that are considered as valid and invalid profiles for

open and nested profiles. In the case of nested inner profile, another inner

2-59

profile which is inside another inner profile will be considered invalid profile.

This is because the inner profile will create a void volume and therefore, in

void volume, any solid should not be present.

In addition, in the case of the nested profile, an outer profile should be

created by a single closed loop. The existence of nested profile indicates a

number of profiles are needed to create the solid and some of the profiles are

adjacent to each other. The presence of other profiles also indicates the solid

will not have homogenous height or angle of revolution. This type of profiles

will be regarded as invalid as a single extrusion and revolved of a profile will

create homogenous height and angle of revolution respectively.

Figure 2.37:Valid and invalid profile iii Axis of rotation cuts the profile (for revolved body): In the case of revolved

body, the position of the axis of rotation will determine the final solid model.

The axis can be one of the outer edges of the profile or another axis that is

been offset from the profile. However, solid can be created if the axis will cut

the profiles. Figure 2.38 shows some of the valid and invalid axis of rotation.

2-60

Figure 2.38: (a) Valid and (b) invalid axis of rotation

2.3.3 Cellular decomposition

The foundation of cellular decomposition is to divide the solid into smaller cells. The basic cells can be in form of cuboid or others. Figure 2.39 shows the cell decomposition of one solid based on cuboid cell and other.

Figure 2.39: a) Cuboid and b) other cell decomposition of a solid model

Cellular decomposition has its shortcoming especially when the cell is only partly occupied by solid and this cell is called as partly solid cell. The problem arises in the identification of the boundary between void and solid. The cellular that have both solid and void will generally regarded as partly occupied solid.

2-61

Regarding the cell as partly occupied cell will also cause another shortcoming.

Two different solid will have similar representation when cellular decomposition is used to represent the solid. This is illustrated in Figure 2.40.

Figure 2.40: Two solid models having same cellular decomposition representation

Implementation of smaller cells will be the solution to overcome the above shortcomings faced by partly occupied cell. However, to have the whole model to be decomposed smaller will be very costly computationally. Start with larger cell and further decomposition is carried out on the partly occupied cell will reduce the computational cost. This method of decomposition is called Octree Adaptive Grid as shown in Figure 2.41.

Figure 2.41: Implementation of Octree Adaptive Grid

2.3.4 Constructive Solid Geometry

Constructive Solid Geometry (CSG) represents solid as hierarchical tree of sub objects. At the leaves of the tree, or can be called as leaf nodes, will be the base body

2-62 such body A to G in Figure 2.42. The leaf node can be primitive bodies, extruded, or revolved bodies. When two or more leaf nodes are combined, they are connected through branches. The connection is done using Boolean Operation. Finally, the final object is created based on the Boolean Operation of the sub-objects as illustrated in

Figure 2.42.

B E A C D F G

A U B C U D F U G

H

(C U D) - (A U B) J

((C U D) - (A U B)) - (F U G) - H - J

Figure 2.42: CSG Tree

The Boolean Operations are

Union (U*): Union will combine two or more objects together. (Figure 2.43a)

Subtraction (-*): Subtraction will remove the object from the original object. There

will be one original object and two or more objects to be removed. (Figure

2.43b)

Intersection (*): Intersection process will leave behind the intersected part of the

selected bodies (Figure 2.43c).

2-63

Figure 2.43: Boolean Operation a) Union, b) Subtraction, and c) Intersection

Some of CSG representation goes further in classification of the base body by its halfspace. For instance, halfspace for cylinder is two planar surface and one cylindrical surface, while halfspace for cuboid is six planar surface as respectively shown in Figure 2.44a and 2.44b.

Figure 2.45: Halfspace of a) cylinder and b) Cuboid

2.3.2 Boundary Representation Modeller

2-64

The foundation B-Reps is the information is stored in form of topology and geometry data. The topology data shows the connectivity information that makes the solid and the geometry is the properties of the matter, whilst in the case of B-Reps, geometry is the properties of the respective topology data. To have better idea of topology and geometry is by taking an example of line. The topology of line is edge and both end points. Each topology will be described by its geometrical properties which curve and vertices are the geometrical properties for edge and point respectively. Table 2.15 shows some other example of topology and geometry data of other entities.

Table 2.15:

Entity Topology Geometry

Line Curve Straight line Point Coordinate of the vertices Circle Curve Circular with radius Point Coordinate of the center point Arc Curve Arc with radius Point Center Point Spline Curve Curve List of point Coordinate of the vertices

To elaborate further the topology and geometry, let take example both profiles in Figure 2.45. Both profiles have the same geometry information but they have different topology information.

Figure 2.45: Profiles that have same topology with different geometry

2-65

In the case of profile in Figure 2.46, both profiles have the same topology but having different geometry information. Even a profile is been moved to another position, it will maintain the topology whilst having different geometrical data as the geometrical data relies on the position of the profile.

Figure 2.46: Profiles that have different geometry with the same topology

When the topology and geometry relationship is applied to solid model, the general relationship is shown in Figure 2.47. However, the topology and geometry relationship relies on the solid modeler kernel. Different kernel will have different relationship. The vertical relationship is the topology relationship which will maintain the integrity of the solid model, whilst the horizontal relationship is the relationship between specific topology and its geometry. However, not all topology will have geometry.

2-66

Figure 2.47: General topology and geometry of B-Reps modeler.

Solid: Solid is the highest topology data. Solid has no geometry. Solid is made of

connected faces that create the boundary of the solid.

Face: Face is the next topology after solid. As far as topology is concerned, the

connectivity between face is mapped. For example, Figure 2.48 shows the

connectivity of a cylinder and cuboid.

In the case of cylinder, it will have connectivity of F1 – F2 – F3. The

geometry will further classify the surface type of the face. Types of surface are

planar, cylindrical, spherical, conical, and free form surface. In the case of the

cylinder, the surface of F1 and F3 are plane, and the surface for F2 is

cylindrical.

( a ) ( b)

Figure 2.48: Face connectivity of (a) cylinder and (b) cuboid

2-67

For each surface, it will be described by one normal vector, one reference

vertex, and one vector on the surface. Figure 2.49 shows the geometrical

properties of the surface.

Figure 2.49: Types of surface

Loop: Every face must have loop. Outer loop will make the outer boundary of the

face, whilst the inner loop will create void space in the face. To maintain the

side of the face either void or solid, counter clock wise loop direction is

designated for outer boundary, whilst clockwise direction loop is designated

for inner loop as illustrated in Figure 2.50.

Figure 2.50: Direction of loops for outer and inner

Edge: Loop will be further divided into edges that make up the outer or inner loop.

The geometry of edge is the curve which is represented by parametric curve.

The direction of loop is used to set start and end point of the curve. Since one

edge will be shared by two faces and two loops, a single edge will declared

twice based on its parent face as shown in Figure 2.51. The geometry of edge

is curve. The type of curve has been discussed in Section 2.1.2.

2-68

Figure 2.51: Direction of edges on the adjacent faces

Vertex: Finally, every edge will have vertices. The geometry of the vertex is

coordinate of the vertex.

B-Reps modeler will store these topology and geometry data to maintain the integrity of the solid model. The actual topology and geometry data will be further discussed in Chapter 5.

The topology relationship and the mathematical representation of its geometrical data will in fact determine the boundary of the solid. The mathematical representation of the surface will determine the point is whether above, on, or below the surface. The point is considered as inside the solid model when the point is below all of the surfaces.

Moreover, some of surfaces are mathematically represented without any boundary. For instance, planar surface is infinite plane surface and cylindrical surface is in fact a cylindrical surface with infinite length. To main the boundary of the solid, other geometrical properties of other topology data will be referred. As such the boundary of the planar surface will be defined by the curve of the edges and finally the vertices of the point will set the boundary of the curve.

2-69

In all, Figure 2.52 shows network of the topology of a solid. The geometry of the topology can be defined on each topology. The search process can be carried out based on these connectivity. As such, the search of the adjacent vertex of a curve can be done by searching through edge. This search becomes more complex when the search for adjacent face of a vertex can only be carried out by searching through solid and then the search continues until all the faces that shares the same vertex are identified.

Figure 2.52: Description of solid

Euler Poincare Law

Euler Poincare Law will govern the presence of the solid. Equation 2.37 is Euler

Poincare Law that governs the numbers of each topology. The solid is present when body (B) is a round number.

2-70

2 (B- G ) = V – E + F – I … (2.37)

Where B: number of bodies G: number of genus (hole)

V: number of vertex E: number of edges

F : number of face I: number of inner loop

The number of topology can be easily counted for polyhedral bodies, however of a cylinder, V = 2, E = 3, F = 3, and I = 0 as shown in Figure 2.53.

Figure 2.53: Topology Data for cylinder for Euler Poincare Law

However, Euler Poincare Law cannot be used on the part that has intersected cylindrical faces as shown in Figure 2.54.

Figure 2.54: Invalid parts for Euler Poincare Law

Example 2.13

2-71

Show that Euler Poincare Law will show that both models in Figure 2.55 are valid model.

( a ) ( b )

Figure 2.55: Models

Solution

To prove the models are valid models, the number of body (B) in Euler Poincare should be 1. Figure 2.56 shows graphically the number of genus, vertices, faces, inner loops, and edges of both models.

Figure 2.56: The definition of genus, vertices, faces, inner loops and edges for

models in Figure 2.55.

2-72

For model in Figure 2.55a For model in Figure 2.55a

2 (B- G ) = V – E + F – I

2 (B - 1 ) = 16 – 24 + 10 – 2 2 (B- 1 ) = 4 – 6 + 4 – 2

B = 1 B = 1 (Ans)

Both models are valid models because the number of body in Euler Poincare Law are equal to 1.

2.4 POINT CLOUD REPRESENTATION

Point Cloud is represented by a set of points and the points are represented as coordinates of the point. These data sets are generated from 3D scanner, Contact

Measuring Machines (CMM) digitizer or any other digitizers. The aim of point cloud is for reverse engineering to model the part that has been digitized. The foundation of point cloud is the conversion of the set of points into mesh and then into surface and finally solid. There are a number of software has been developed based on cloud point representation. Some of point cloud softwares are stand alone and others can be integrated into main CAD packages as module.

Amongst the issue in cloud point is the algorithm to filter noises in the data, stitch 3D point clouds together, and segmentation of the parts and generation of surface. Nowadays, the applications of cloud point can be seen as a tool for reverse engineering. Some researchers go further to use the point cloud to develop 3D anthropometric data [ref]. These 3D anthropometric data have direct implication on textile industries which the detail sizing of cloth can be developed.

2-73

Another application of point cloud is used as Graphical User Interface (GUI).

By converting the point cloud of human body into human kinematic figure, any movement of certain body can be detected. X Box system and Smart Television are amongst the example of using this technology for their GUI.

2-74

CHAPTER 3

TRANSFORMATION

This chapter discusses the transformation in both 2D and 3D environment. Then, it will follow with the discussion on the compound transformation. The discussion proceeds with the application of transformation in the projection for visualization purposes. Finally, the discussion on the application of transformation in animation and modelling are followed.

3.1 2D AND 3D TRANSFORMATION MATRIX

Transformation has been used widely in any geometric modeling. Moving a circle on a screen requires transformation matrix, or even displaying the solid object also requires transformation matrices.

In CAD, the transformation matrix will be applied to geometrical properties of the entities such as coordinates of the vertex. The geometrical properties can be represented in three forms; Cartesian coordinate, vector coordinate, and homogenous coordinate. Table 3.1 shows the representation of all the coordinate systems.

Table 3.1: Coordinate System

Type 2D 3D

Cartesian Coordinate (x,y) (x, y, z)

3-1

Vector Coordinate x x [x y] or   y [x y z] or     y z

Homogenous Coordinate x x   [x y 1] or y y   [x y z 1] or   1 z   1

In the case of applying transformation matrix to the geometrical properties, homogenous coordinate system is the suitable representation. The third axis for 2D and fourth axis for 3D are in fact the homogenous axis. Basically, all the coordinates can be scaled individually on this axis. As in the above example, the homogenous coordinate is set to 1, it shows the scaling factor along the homogenous axis is 1 and therefore, it will maintain its original coordinate system. Moreover, the introduction of homogenous coordinates allows the matrix calculation to be carried out and therefore, calculation related to geometrical properties will be easier to be done.

a1 a2 a3   x' y' 1 x y 1b1 b2 b3 … (3.1) c1 c2 c3

Wherex' y' 1: homogenous representation of the coordinate after

application of the transformation

x y 1: Homogeneous representation of the original coordinate

a1 a2 a3   b1 b2 b3 : Matrix c1 c2 c3

3-2

Equation 3.1 shows the calculation using matrix. The matrix is applied to coordinate [x y 1] and as a result, coordinates [x’ y’ 1] are the resulted of the application of the matrix to [x y 1].

Matrix in Eq 3.1 can be replaced with transformation matrix. As a result, Eq.

3.2 ca be applied to 2D (2D).

x' y' 1 x y 12D  … (3.2)

Where: 2D : 2D transformation matrix

Similarly, Eq 3.3 is applicable to 3D coordinate system

x' y' z' 1 x y z 13D  … (3.3)

Where: 3D : 3D transformation matrix

Similarly, the application of the transformation can have in other format as in

Eq. 3.4 and 3.5.

x' x y'   y … (3.4)    2D   1  1

x' x y' y       … (3.5) z' 3D z     1  1

In this book, format as in Eq 3.2 and 3.3 are used. 2D transformation is 3 x 3 matrix format, whilst 3D transformation is 4 x 4 matrix format. In Eq 3.2 and 3.3, there is only one vertex is used in the calculation, however in practical more vertices

3-3

are required. Therefore, Eq 3.2 and 3.3 are expanded to Eq. 3.6 and 3.7 to cater n vertices.

x'1 y'1 1 x1 y1 1 x' y' 1 x y 1  2 2    2 2   … (3.6)  ...   ...  2D     x'n y'n 1 xn yn 1

Where x’i, y’i: 2Dcoordinate of i vertex after application of transformation

xi, yi: 2D coordinate of i vertex before application of transformation

x'1 y'1 z'1 1 x1 y1 z1 1 x' y' z' 1 x y z 1  2 2 2    2 2 2   … (3.7)  ...   ...  3D     x'n y'n z'n 1 xn yn zn 1

Where x’i, y’i, z’i: coordinate of i vertex after application of transformation

xi, yi, zi: 3D coordinate of i vertex before application of transformation

Prior to apply the matrix transformation, the model can be represented into homogenous matrix format. Following in Table 3.2 shows the representation of entities into their matrix representation.

Table 3.2 Matrix representation of the sample entities

Entities Matrix Representation

10 20 1 20 20 1   30 30 1   30 20 1

3-4

 0 0 10 1   10 0 0 1  0 10 0 1

(0,1,1) 0 0 0 1 (1,1,1)   1 0 0 1 (0,0,1) 1 1 0 2 (0,1,0)   ......  Z (1,1,0) Y 1 1 1 1 (0,0,0) X (1,0,0)

3.2 FORMS OF TRANSFORMATION

This section discusses the matrix of the selected transformation. The application of the transformation matrix will be similar regardless whether the 2D or 3D transformation. However, there are two differences between them, especially when the transformation requires reference. The first one, when 2D transformation requires a point as the reference, the same 3D transformation will require axis. The second one is when 2D transformation requires axis, the same 3D transformation requires plane.

Figure 3.1 graphically illustrates the differences.

3-5

Figure 3.1 Differences between the reference of 2D and 3D transformation

3.2.1 Translation

Translation will move one entity to another position. Figure 3.1 shows the translation of 2D and 3D entities as well as the initial and final coordinates. Mathematically, Eq

3.8, 3.9, and 3.10 can be used to calculate the position after translation is applied.

Figure 3.1 Translation of 2D and 3D entities

x' x  x … (3.8)

y' y  y … (3.10)

3-6

z' z  z … (3.11)

where x, y, z: translation based on the respective axis.

The matrix representation for translation will be as follows

 1 0 0 T   0 1 0 …(3.12) 2D   x y 1

 1 0 0 0  0 1 0 0 T    …(3.13) 3D  0 0 1 0   x y z 1

3.2.2 Rotation

Rotation is a process to rotate an entity about rotation center. To rotate 2D entity, the rotation center will become the reference, whilst for 3D rotation, the reference for rotation will be an axis. Eq 3.14 and 3.15 will calculate the position of the vertex after rotation is applied on 2D entities and Figure 3.2 illustrates the 2D rotation. The center of rotation for both equation is at (0, 0)

x' xcos()  ysin() … 3.14

y' xsin()  y cos() … 3.15

3-7

Figure 3.2 Rotation about a vertex

In the case of 3D rotation, the rotation is carried out on axis, x, y, and z axis.

The equation to calculate the position of the final entity after the rotation is applied according to the axis is as the following.

X Axis: x' x … 3.16

y' y cos()  z sin() … 3.17

z' ysin()  z cos() … 3.18

Y Axis: x' z sin()  xcos() … 3.19

y' y … 3.20

z' z cos()  xsin() … 3.21

Z Axis: x' xcos()  ysin() … 3.22

y' xsin()  y cos() … 3.23

z' z … 3.21

These equations can form the following 2D and 3D matrices are as the following:

2D rotational matrix

 cos sin  0 R   sin  cos 0 …(3.22) 2D    0 0 1

3D rotational matrix: X axis

3-8

1 0 0 0 0 cos sin  0 R    …(3.23) 3DX 0  sin  cos 0   0 0 0 1

3D rotational matrix: Y axis

cos 0  sin  0  0 1 0 0 R    …(3.24) 3DY sin  0 cos 0    0 0 0 1

3D rotational matrix: Z axis

cos sin  0 0 sin  cos 0 0 R    …(3.25) 3DZ  0 0 1 0    0 0 0 1

All the equations (Eq 3.14 – 3.21) and matrices (Eq 3.22 – 3.23) are based on the assumption the center of rotation are at origin (0, 0) for 2D rotation and at the principal axis for 3D rotation. Any rotation that is carried out other than the origin for

2D and the principle axis for 3D, the rotational center should be transformed to the reference center point or principal axis. Therefore, translation should be carried out to transform the reference as the center or axis of rotation before applying the rotational matrix.

The calculated vertices when rotation is applied is based on center or axis of the translated one. However, rotation should be carried on the specified vertex or axis, and therefore, the calculated vertices should be translated back to ensure rotation is based on the actual the center or axis.

3-9

In all, any rotation that is not at the center point for 2D or principal axis for 3D, translation is firstly carried out to make the reference point to be either center or principal axis and it is followed with the application of the rotation transformation.

Finally, translation is carried out to make the calculated vertices to be referred to their earliest origin. Therefore, the procedure will be as follows: i. Translate the center or axis of rotation to its origin vertex or principle axis.

In the case of 2D, the coordinate of rotation center will be used as the reference, whilst in the case of 3D, any vertex on the axis can be used as the reference. Let say, the actual center of rotation is (x, y) and any point of the axis of rotation is (x, y, z).

The translation should be done to ensure (x, y) turns to (0, 0) and (x, y, z) turns to (0,

0, 0), therefore the translation matrix will be the negative value of every coordinate as such x and y for 2D will be deducted by the value x and y for 2D translation and additional z will be deducted by the value of z for 3D translation.

The translation matrix before the application rotational matrices is

 1 0 0 2D T   0 1 0 … (3.26) 2D1    x  y 1

 1 0 0 0  0 1 0 0 3D T    … (3.27) 3D1  0 0 1 0    x  y  z 1

Therefore, the original vertices (xi, yi) for 2D entities and (xi, yi, zi) for 3D entities will be translated to (x’i, y’i) and (x’i, y’i, z’i) respectively using 3.27 and 3.28 for 2D and

3D translation respectively.

3-10

x'1A y'1A 1 x1 y1 1 x' y' 1 x y 1  2 A 2 A    2 2   … (3.28)  ...   ...  2D1     x'nA y'n A 1 xn yn 1

x'1A y'1A z'1A 1 x1 y1 z1 1 x' y' z' 1 x y z 1  2 A 2 A 2 A    2 2 2   … (3.28)  ...   ...  3D1     x'nA y'nA z'nA 1 xn yn zn 1

This translation process will make the reference center point and principle axis to become (0, 0) and (0, 0, 0) respectively and this causes the rotational transformation can be carried out in step (ii). ii. Apply the rotation matrix

As the translation matric converts the center point to (0, 0) for 2D or (0, 0, 0) for

3D, rotation can be applied to the entities. Eq 3.29 and 3.30 calculates the vertices when rotation matrix is applied that will transform (x’A, y’A) or (x’A, y’A, z’A) to (x’B, y’B) or (x’B, y’B, z’B), respectively.

x'1B y'1B 1 x'1A y'1A 1 x' y' 1 x' y' 1  2B 2B    2 A 2 A R  … (3.29)  ...   ...  2D     x'nB y'nB 1 x'nA y'nA 1

x'1B y'1B z'1B 1 x'1A y'1A z'1A 1 x' y' z' 1 x' y' z' 1  2B 2B 2B    2 A 2 A 2 A R  … (3.30)  ...   ...  3D     x'nB y'nB z'nB 1 x'nA y'nA z'nA 1 iii. Apply translation to compensate the application the first translation

3-11

In step I, the application of the translation matrix will translate all the coordinates to its original position with the intention to make the center of rotation will be at its origin or principle axis. Therefore, at this step, it will translate back all the coordinates to their original position. Therefore, translation matrix is applied that has the negative value of the translation applied in step 1.

The translation matrices are as follows:

1 0 0 2D T  0 1 0 … (3.31) 2D2   x y 1

1 0 0 0 0 1 0 0 3D T    … (3.32) 3D2 0 0 1 0   x y z 1

The final vertices can be calculated using Eq 3.32 and 3.31 that will translate

(x’B, y’B) or (x’B, y’B, z’B) to (x’C, y’C) or (x’C, y’C, z’C) to (x’C, y’C) or (x’C, y’C, z’C).

x'1C y'1C 1 x'1B y'1B 1 x' y' 1 x' y' 1  2C 2C    2B 2B T  … (3.33)  ...   ...  2D2     x'nC y'nC 1 x'nB y'nB 1

x'1C y'1C z'1C 1 x'1B y'1B z'1B 1 x' y' z' 1 x' y' z' 1  2C 2C 2C    2B 2B 2B T  … (3.34)  ...   ...  3D2     x'nC y'nC z'nC 1 x'nB y'nB z'nB 1

Example 3.1 a) Create the transformation matrices when shape is rotated by 35o in counter

clockwise direction and point (4, 5) is the center of rotation,

3-12

b) Calculate the transformed vertices if the polygon with the following vertices

are been transformed using the similar rotation in (a). The vertices are (10, 8),

(16, 8), and (13, 13).

Solution

(a) Since the shape is not rotated at (0,0), the translation must be applied before and after the rotation matrix.

Therefore, the compound matrix will be

comp  T1RT2 ,

 1 0 0 T   0 1 0 1    4  5 1

Dx = -4 and Dy = -5 to make rotation point transform from (4, 5) to (0,0)

 cos35o sin 35o 0  o o  R   sin 35 cos35 0    0 0 1

Rotation can be applied once the origin is transformed into (0, 0)

1 0 0 T  0 1 0 2   4 5 1

Dx = 4 and Dy = 5 to make rotation point transform from (0, 0) to its original coordinate (4,5)

As a result the compound transformation matrix will

3-13

 1 0 0 cos35o sin 35o 01 0 0      0 1 0  sin 35o cos35o 0 0 1 0 comp      4  5 1 0 0 14 5 1    0.819 0.574 0     0.574 0.819 0  3.591 1.39 1

( b ) The homogenous representation of the polygon will be

10 8 1 P  16 8 1  polygon   13 13 1

As a result, the final vertices after the transformation will be

x1' y1' 1 x ' y ' 1  P   2 2   polygon comp  x3 ' y3 ' 1 10 8 1 0.819 0.574 0     16 8 1 0.574 0.819 0 13 13 1 3.591 1.39 1  7.2 10.9 1    12.1 14.3 1  6.8 16.7 1

Therefore, the respective transformed vertices will be (7.2, 10.9), (12.1, 14.3), and

(6.8, 16.7) and Figure 3.3 illustrates the process of the rotation graphically

3-14

Figure 3.3 Example 3.1

3.2.3 Mirror

Mirror is similar to process of sitting in a mirror, the reflection inside the mirror is actually the result of the mirroring process. In 2D, x and y axis are used as mirror and in 3D plane, plane xy, yz, and xz will become the mirror.

Eq 3.35 and 3.36 are the matrices for 2D mirror.

1 0 0 X axis M  0 1 0 … Eq 3.35 2D X   0 0 1

1 0 0 Y axis M   0 1 0 … Eq 3.36 2DY    0 0 1

Eq 3.36 – 3.38 are the matrices for 3D mirror based on the plane.

3-15

1 0 0 0 0 1 0 0 Plane XY T    … (3.37) 3D XY 0 0 1 0   0 0 0 1

1 0 0 0  0 1 0 0 Plane YZ T    … (3.38) 3DYZ  0 0 1 0    0 0 0 1

1 0 0 0 0 1 0 0 Plane XZ T    … (3.39) 3D XZ 0 0 1 0   0 0 0 1

In mirror process, the mirror axis or planes are based on the principle axis. If the mirror axis or planes are not based the principle axis, translation matrix should be before to allow the mirror axis and plane to set on principle axis and after to convert the coordinates to their original coordinates.

In 2D mirror process, the axis can translated into straight line equation as in the following.

X axis y = 0 … (3.40)

Y axis x = 0 … (3.41)

Therefore, if the mirror process is carried out using axis other than X or Y axis, the mirror axis must be converted into X or Y axis that is having straight line equation as in equation 3.40 or 3.41 respectively. This is done by applying the translation matrix before mirror process can take place. This translation process will convert the mirror axis as X or Y principle axis.

If the mirror axis is parallel to X axis, the equation of the mirror axis will 3-16

y = Cx … (3.42)

where Cx: constant

Therefore, to convert the mirror into X principle axis, translation matrix as in equation 3.43 is applied.

1 0 0 T  0 1 0 … (3.43) 2DX 1   0  Cx 1

Then, the mirror can be applied as the mirror axis is equal to X principle axis.

After that translation will be applied to convert all the coordinates to its original position. The translation matrix after the mirror will be as in equation 3.44.

1 0 0 T  0 1 0 … (3.44) 2DX 2   0 Cx 1

In the case of the mirror axis is parallel to Y axis, the equation for mirror axis will be as in equation 3.45.

x = Cy … (3.45)

where Cy : constant

Therefore, translation by –Cy is carried out on x coordinate to change the mirror axis as principle y axis (or x = 0). Equation 3.46 will convert all the coordinates.

 1 0 0   T2DY 1   0 1 0 … (3.46)    Cy 0 1

3-17

Then, mirror process using Y principle axis is carried out. It will be followed with translation using equation 3.47 to make all the entities referred to their original coordinate system.

 1 0 0   T2DY 2   0 1 0 … (3.47)   Cy 0 1

Similarly, in the case of 3D mirror, translation before (T3D-1) and after ((T3D-2) should be applied to homogenous matrix if the mirror plane is parallel to XY, YZ, or

ZX plane. The translation matrices are as follows

Parallel to XY plane: z coordinate is constant (Zxy)

1 0 0 0 0 1 0 0 T    …(3.48) 3D XY 1 0 0 1 0   0 0  Zxy 1

1 0 0 0 0 1 0 0 T    … (3.49) 3D XY 2 0 0 1 0   0 0 Z xy 1

Parallel to YZ plane: x coordinates is constant (Xyz)

 1 0 0 0  0 1 0 0 T    …(3.50) 3DYZ 1  0 0 1 0    X yz 0 0 1

 1 0 0 0  0 1 0 0 T    … (3.51) 3DYZ 2  0 0 1 0   X yz 0 0 1 3-18

Parallel to ZX plane: y coordinates is constant (Yzx)

1 0 0 0 0 1 0 0 T    …(3.52) 3DZX 1 0 0 1 0   0 Yzx 0 1

1 0 0 0 0 1 0 0 T    … (3.53) 3DZX 2 0 0 1 0   0 Yzx 0 1

However, the above matrices cannot be applied to non-parallel mirror axis or plane as shown in Figure 3.4. Mapping or compound matrices of rotation and translation are required. The non-parallel mirror axis or plane will be discussed mapping matrix and compound matrix.

Figure 3.4 Non-parallel mirror axis or plane

Example 3.2

A triangle with A (1,1), B (1,3) and C (2,2) has been subjected to the following transformation. Answer the following questions.

3-19

a) Write homogenous representation of the triangle.

b) Write the composite transformation matrices when mirror is applied to the

triangle using axis x = 0 and the calculated the vertices after the mirroring

process is carried out

c) Write the composite transformation matrices when mirror is applied to the

triangle using axis x = -2 and the calculated the vertices after the

mirroring process is carried out

Solution a. The homogenous representation of the triangle is

1 1 1 P  1 3 1  triangle   2 2 1 b. Mirror axis x = 0 is similar to mirror axis at Y principle axis, therefore the

mirror matrik will be

1 0 0 M   0 1 0 2DY    0 0 1

Therefore, the vertices after being mirrored are

3-20

x1' y1' 1 x ' y ' 1  P M  2 2   trianlge  2DY  x3 ' y3 ' 1 1 1 11 0 0     1 3 1 0 1 0 2 2 1 0 0 1 1 1 1    1 3 1  2 2 1

Therefore A’ (-1, 1), B’ (-1, 3), and C’(-2, 2). Figure 3.5a illustrates graphically the mirroring process. c. When mirror axis x = -2, the mirror must be converted to x = 0 by translation

x = 2 before the mirroring process. After the mirroring process, it will be

converted to its original coordinate by translation x = -2, therefore the mirror

matrik will be

x1 ' y1 ' 1 x ' y ' 1  P  M   2 2   trianlge  1  2DY  2  x3 ' y3 ' 1 1 1 11 0 01 0 0 1 0 0       1 3 10 1 0 0 1 0 0 1 0 2 2 12 0 1 0 0 1 2 0 1  5 1 1     5 3 1  6 2 1

Therefore A” (-5, 1), B”(-5, 3), and C”(-6, 2). Figure 3.5b illustrates graphically the mirroring process.

3-21

( a )

( b )

Figure 3.5 Example 3.2

3.2.4 Scaling

Scaling is carried out when we need to make certain entity bigger or smaller. The scaling process is referred to one origin vertex for both 2D and 3D scaling. Figure 3.6 illustrates the concept of scaling graphically. As a result of the scaling, the final coordinate is proportional to the scale that is applied, and this causes Eq 3.54 to 3.56 can be used calculating the final coordinates.

3-22

Figure 3.6 Scaling concept

x’ = Sx x … (3.54)

y’ = Sy y … (3.55)

z’ = Sz z … (3.56)

Based on these equations, the scaling matrices will be as the following:

SX 0 0 S   0 S 0 … (3.57) 2D  Y   0 0 1

SX 0 0 0  0 S 0 0  Y  S3D  … (3.58)  0 0 SZ 0    0 0 0 1

Matrices in Eq 3.57 and 3.58 indicate the scaling can be done on individual axis.

However, more commonly, the scale for all the axis is equal and therefore both matrices can be transformed to the following matrices.

3-23

C 0 0 S  0 C 0 … (3.59) 2D   0 0 1

C 0 0 0 0 C 0 0 S    … (3.60) 3D 0 0 C 0   0 0 0 1

Therefore, since the origin of the scaling must be at (0, 0) or (0, 0, 0) for 2D and

3D respectively, translation before and after applying the scaling must be carried out if the reference vertex for scaling is not at (0, 0) or (0, 0, 0).

Example 3.3

A cube (1 x 1 x 1) as shown in Figure 3.7a is transformed into the solid as shown in

Figure 3.7b. Establish the transformation matrices for this transformation. The scaling matrix transformation based on reference point of (0, 0, 0) is as in the following and calculates the vertices after being scaled.

Solution

Figure 3.7 Example 3.3

Solution

3-24

The homogenous representation of the cube is

0 0 0 1   1 0 0 1 1 1 0 1   0 1 0 1 M     0 0 1 1   1 0 0 1 1 1 1 1   0 1 1 1

To create the shape as in Figure 3.7b, the cube must be firstly scaled by 4 along the Y axis and then, followed with the translation by x = 4. Therefore, the transformation will be

comp  ST  1 0 0 01 0 0 0 0 4 0 00 1 0 0     0 0 1 00 0 1 0    0 0 0 14 0 0 1 1 0 0 0 0 4 0 0    0 0 1 0   4 0 0 1

The vertices after being transformed will

3-25

M ' M Tcomp  0 0 0 1   1 0 0 1 1 1 0 11 0 0 0   0 1 0 1 0 4 0 0     0 0 1 10 0 1 0    1 0 0 14 0 0 1 1 1 0 1   0 1 1 1 4 0 0 1   5 0 0 1 5 4 0 1   4 4 0 1    4 0 1 1   5 0 0 1 5 4 0 1   4 4 1 1

3.2.5 Shearing

Shearing is a process to translate entity along certain axis and the amount of translation increases linearly based on the height of point above the reference axis.

Figure 3.8 Shearing

If the shearing is carried out along the X axis, any point on X principle axis will not be translated. The point above the X principle be translated linearly by a product of a constant  and y coordinate. Therefore, the new x coordinates can be calculated

3-26

using equation 3.61, whilst there is no change in y coordinate. This is graphically illustrated in Figure 3.8a.

X axis: x' x  y … (3.61)

y' y … (3.62)

Figure 3.8b illustrates the similar shearing process along the Y axis. Hence, the transformation of coordinates can be calculated using equation 3.63 and 3.64.

Y axis: x' x … (3.63)

y' x  y … (3.64)

Therefore, the 2D shear transformation matrices are as follows:

Shearing along X axis.

1 0 0 Sh   1 0 … (3.65) 2DX   0 0 1

Shearing along the Y axis.

1  0 Sh  0 1 0 … (3.66) 2DY   0 0 1

In 3D, the shearing process can be done along the x axis, y axis, or z axis. If the shearing is carried out along the plane XY, translation will be carried out along the X and Y axis and at the same time, z coordinate will be maintained. Therefore, the following equation will calculate the translated coordinate

Plane XY x' x z … (3.67)

3-27

y' x  z … (3.68)

z' z … (3.69)

The shearing matrix will be as in equation 3.70

1 0 0 0 0 1 0 0 S    … (3.70) 3DXY   1 0   0 0 0 1

In similar manner, the shearing matrires along plane XZ and YZ will be as the following

1 0 0 0  1  0 Plane XZ: S    … (3.71) 3DXZ 0 0 1 0   0 0 0 1

Where:  is constant for translation along X axis

is constant for translation along Z axis

1   0 0 1 0 0 Plane YZ: S    … (3.72) 3DYZ 0 0 1 0   0 0 0 1

Where:  is constant for translation along Y axis

is constant for translation along Z axis

Example 3.4

Profile A to L forms a letter M as shown in Figure 3.x. The intention is to draw an italic M, which vertical line is slanted by 15o. Based on shearing transformation matrix, calculate all the respective points that form the italic letter M.

3-28

Figure 3.9 Profile M

Solution

Firstly, letter M profile must be represented as its homogenous representation

 0 0 1    0 40 1 10 40 1   20 30 1 30 40 1   40 40 1 M     40 0 1   30 0 1 30 25 1   20 15 1   10 25 1 10 0 1

Then calculate the shearing factor

x' x  ysin(15o )

y' y

Therefore,  = sin (15o) and the shearing matrix is

 1 0 0 Sh  sin(15o ) 1 0 2DX    0 0 1 3-29

The italic M vertices are

 1 0 0  o  M *  M sin(15 ) 1 0  0 0 1  0 0 1   10.4 40 1 20.4 40 1   27.8 30 1 40.4 40 1   50.4 40 1     40 0 1    30 0 1 36.5 25 1   23.9 15 1   16.5 25 1  10 0 1

3.2.5 Mapping

The application o global and local coordinate systems are been used during modelling. The need of the local coordinate system is due to the need of drawing entities on different plane. When the entities are drawn using the local coordinate system, the coordinates of the vertices will be referred to the local coordinate system.

These entities must maintain the relationship with the global coordinate system and mapping process will maintain the relationship between two coordinate system.

Figure 3.10 shows the two coordinate systems and point P can be described by both of the coordinate system. Since currently P is described by principle coordinate system, mapping matrix will calculate the coordinate of point P when is the referred to second coordinate system.

3-30

Figure 3.10 Mapping concept

Normally the new coordinate will be rotated and translated, therefore the mapping matrix comprises of both transformation as shown in the following equations:

a11 a21 0 2D Mapping M  a a 0 … (3.73) 2D  12 22  x y 1

a11 a21 a31 0 a a a 0  12 22 32  3D Mapping M 3D  … (3.74) a13 a23 a33 0   x y z 1

For 2D matrix, a11 – a22 and 3D matrix a11 – a33 are the rotational matrix, while the last row of both matrices is the translation matrix. Therefore, it can be furthered expanded to the following matrices.

 cos sin  0 2D Mapping M   sin  cos 0 … (3.75) 2D    x y 1

3D Mapping

3-31

 1 0 0 0  0 cos sin  0 R    …(3.76) 3D X  0  sin  cos 0   x y z 1

cos 0  sin  0  0 1 0 0 R    …(3.77) 3DY sin  0 cos 0    x y z 1

cos sin  0 0 sin  cos 0 0 R    …(3.78) 3DZ  0 0 1 0    x y z 1

Parameters

There are two parameters that need to follow convention; amount of translation in every axis and angle for rotation. In order to make the convention, we have to understand the foundation. Figure 3.10 shows that point P needs to be mapped to the new coordinate system (X’Y’)

Referring to the principal coordinate system (XY), origin of the mapped coordinate system is (3, 2). Currently P is (x, y) when it is referred to the principal coordinate system and we need to calculate the coordinate of P when is mapped to

X’Y’ coordinate system. Similar situation occurs on the origin of both coordinate systems, both origins should be (0, 0). To make the X’Y’ coordinate system to be (0,

0), the coordinate should be translated by Dx = -3 and Dy = -2. Therefore, the amount of the translation needed will be the negative value of the origin of mapped (X’Y’) coordinate system.

3-32

The foundation of the translation is that it should be inverse to the amount of translation of the mapped cs. Similar for angle of rotation, it should be negative to conventional Right Hand Rule and as a result for the case in Figure 3.10, the rotation angle should be -30o. Please take note that Right hand rule is used to set the positive or negative values of the angle.

The previous mapping is based on the conventional coordinate system, means that the axis of x, y, and z is based on right hand rule. However, the mapping may occur and the coordinate system is not following the conventional one. Mapping the default coordinate system of the computer graphic system to the conventional coordinate system is not following the conventional coordinate system.

Figure 3.11 shows the default position of the conventional and computer graphic system coordinate system. The origin of conventional coordinate system will be positioned at the bottom left of the screen, whilst the origin of the graphic screen coordinate system is at the top left of the screen. Visually, we can say that only the y axis is been rotated by 180o.

Figure 3.11 Mapping of the default CS graphic system to common cs

3-33

Since matrices in equation 3.73 to 3.78 require all the axis of the rotated at the same angle, these matrices should be modified to cater the need of not having all the axis to be rotated at the same angle. Therefore, the matrices can be expanded to individual rotation on each axis on each column as stated in equation 3.79 for 2D and

3.80 for 3D.

nx ny 0 2D Mapping M  o o 0 … (3.79) 2D  x y  x y 1

nx ny nz 0 o o o 0  x y z  3D Mapping M 3D  … (3.80)  px py pz 0   x y z 1

The first column is the transformation needed for x coordinate, the second and the third column are the transformation needed for y and z coordinates respectively.

Referring back to the problem in Figure 3.11 and assuming the translation matrix has been solved, point P is the point using the graphic screen coordinate system and point

P’ is the mapped point P using the principle coordinate system. The relationship between them is as follows:

x' = x

y’ = -y

Based on the above relationship of

' x  nx x  ny y , nx = 1 and ny = 0 to fullfil x’ = x

' y  ox x  oy y ox = 0 and oy = -1 to fullfil y’ = -y

Therefore, the mapping matrix will be 3-34

 1 0 0 M   0 1 0 2D   x y 1

Similarly, the mapping matrix can be derived from the rotational matrix, where angle of rotation 0o and 180o are used for x and y axis respectively.

o o nx = cos x = cos 0 = 1 ox = -sin y = -sin 180 = 0

o o ox = sin x = sin 0 = 0 ox = cos y = cos 180 = -1

As a result, the same mapping matrix is formed

Example 3.5

Figure 3.12 shows a square is mirrored using axis 2. Answer the following questions based on the information given

Figure 3.12 Problem of example 3.5 i. Write the homogeneous representation of the square ii. Calculate the coordinates of the mirror square using the compound

transformation of rotation and translation. iii. Calculate the coordinates of the mirror square using the mapping transformation

matrix

3-35

Solution i. The homogenous representation of the square

20 20 1 30 20 1 [K]    30 10 1   20 10 1 ii. Mirror using the translation and rotational matrix

Figure 3.13: Method 1

To get all the coordinates of the square after being mirrored, the current CS have to go through the following transformation.

a) The coordinate system must move to point (10, 5). This causes the point (10,

5) turns to (0,0) as shown in Figure 3.13a.

 1 0 0 T   0 1 0 1   5 10 1

3-36

b) Rotate the coordinate system by -40o and this causes the mirror axis and x axis

of the coordinate system to be coincided as shown in Figure 3.13b.

 cos(40o ) sin( 40o ) 0  o o  R1   sin( 40 ) cos(40 ) 0    0 0 1

c) Mirror the square using x axis as the mirror axis as shown in Figure 3.13c.

1 0 0   M  0 1 0 0 0 1

d) Rotate the coordinate system by 400 as shown in Figure 3.13d.

 cos(40o ) sin( 40o ) 0  o o  R2   sin( 40 ) cos(40 ) 0    0 0 1

e) Translate back the coordinate system to its original position as shown in

Figure 3.13e.

1 0 0 T  0 1 0 2   5 10 1

Therefore the compound matrix is

comp  T1R1M R2 T2  iii. Method using the mapping matrix

3-37

Figure 3.14 Method 2 a) Mapping the square based on the X’Y’ coordinate system as shown in Figure

3.14a.

In mapping transformation matrix, two parameters, angle and translation, are required.

= -40O

o Dx1 = -11.18cos (23.4 ) = -10.26

o Dy1 = -11.18 sin (23.4 ) = -4.44

Therefore, the mapping transformation matrix is

 cos(40o ) sin( 40o ) 0  o o  Mp1   sin( 40 ) cos(40 ) 0    10.26  4.44 1 b) Mirror the square based on X’ axis as the mirror axis as shown in Figure 3.xxb.

1 0 0   M  0 1 0 0 0 1

3-38

c) Mapping back the square after the mirror using the original coordinate system

as shown in Figure 3.xxc.

= 40O

Dx2 = 5

Dy2 = 10

 cos(40o ) sin( 40o ) 0  o o  Mp2   sin( 40 ) cos(40 ) 0    5 10 1

Therefore the compound matrix is

comp  Mp1M Mp2 

*Compound matrix for b) and c) is

 0.714 0.985 0    0.985  0.714 0  comp     5.716 6.812 1

Example 3.6

By default every window created has its own Coordinate System (CS) as shown in

Figure 3.15a and the position is set by the raster position such as (10,10) means 10 raster in X and 10 raster in Y direction. However, in practice the CS is set as in Figure

3.15b and according to units either mm or inches.

If one raster is equal to 0.01mm and the size of the window is 1000 raster vertical and

2000 raster horizontal.

3-39

Develop the transformation required to calculate the position of the entities in raster based CS (Figure 3.15a) but for visualization purposes, it seems to refer to Normal

CAD window CS (Figure 3.15b). The entities are comprises four lines to draw a2 if a

2 mm square with the bottom left corner will be at (1, 1). The position of the Normal

CAD window CS is at (2000, 0) of raster based CS.

X

Y default window, raster based window setting. Normal CAD window, unit (mm/ inch) based window setting

Y

X

Figure 3.15 Example 3.6

Solution

The vertices of the square in mm are (1, 1), (3, 1), (3, 3), and (1, 3).

Therefore, in raster unit, the vertices are (10, 10), (30, 10), (30, 30), and (10, 30) and its homogenous representation will be

10 10 1 30 10 1 [K]    30 30 1   10 30 1

The next step is to apply the mapping matrix. Since the position of CAD package CS is at (0, 2000) of the raster CS, therefore x = 0 and y = 2000. Therefore, the mapping matrix is

3-40

1 0 0 M  0 1 0  2D    0 2000 1

The transformed vertices will be

10 10 1 1 0 0 30 10 1 K'  0 1 0 30 30 1   0 2000 1 10 30 1

10 1990 1 30 1990 1    30 1970 1   10 1970 1

Therefore, to draw a 2 mm square, the square comprise of (10, 1990), (30, 1990), (30,

1970), and (10, 1970) vertices must be drawn on the raster-based screen.

3.3 COMPOUND TRANSFORMATION

More often, multiple transformations are applied. The combination of these matrices is called compound transformation, such as the following:

comp  1.2 ...n  … (3.81)

As a result, the coordinates of vertices will be

P' Pcomp 

The main question arises whether the compound transformation should be order or it does not matter. Figure 3.16 shows the application of translation and rotation matrix. Figure 3.16a shows the translation is applied first and then follow with the

3-41

rotation, whilst Figure 3.16b shows the rotation is applied first and then follow with the translation. As a result, the mapped shape is not on the same position, which means that

12  2 1 … (3.82)

Figure 3.16 Application of transformation matrices

Therefore, to create the compound transformation, it must be in sequence.

3.5 PROJECTION USING TRANSFORMATION

Most common, we will draw solid object in 3D. During manipulation during modeling or for documentation purposes, the need to project the model from different view is required. In changing the view point, transformation is applied to model. The orthographic and axometric projections will be discussed in the following section.

3.5.1 Orthographic Projection

Orthographic drawing is created when the object is projected on the basic three planes that are perpendicular to each other. The view point is assumed to be at infinity distance and this projection ray to be parallel to each other, therefore the projection is 3-42

one of the parallel perspective projections. As the projection ray is parallel to each other, it causes the projection is having the true length of the object. Figure 3.17 illustrates the concept of the parallel perspective.

Figure 3.17 Concept of orthographic projection

Furthermore, the plane for the orthographic projection is normal to the view ray.

The basic of orthographic projection is when the object is projected to the three basic planes; XY, YZ, and ZX plane. The transformation matrices of orthographic projection on all the planes are as follows:

1 0 0 0 0 1 0 0 Plane XY O    … (3.83) XY 0 0 0 0   0 0 0 1

0 0 0 0 0 1 0 0 Plane YZ O    … (3.84) YZ 0 0 1 0   0 0 0 1

3-43

1 0 0 0 0 0 0 0 Plane ZX O    … (3.85) ZX 0 0 1 0   0 0 0 1

However, in engineering drawing, additional views, such as auxiliary and sectional views, is basically using orthographic projection. In order to create these additional views, mapping of the coordinate system is required before the projection transformation matrix is applied to create the views. Figure 3.18 shows the application of mapping transformation matrix before application of projection transformation matrix.

Figure 3.18 Application mapping transformation to create auxiliary view projection

Example 3.7

Figure 3.19a is a 3D part. Using the 3D part, develop the orthographic drawing. The bottom left vertex of the orthographic will be at (0, 0) of the 2D environment. The distance between the views is set to 10 mm as shown in Figure 3.19b.

The task is to develop the transformation matrices that is able to transform the vertices of 3D part into vertices that can be used to develop the orthographic drawing.

3-44

l

( a ) (b)

Figure 3.19 Example 3.7

Solution

There are 10 vertices of the part and the vertices are (0, 0, 0), (30, 0, 0), (30, 0, 30), (0,

0, 30), (0, 30, 0), (30, 30, 0), (30, 30, 15), (15, 30, 30), (0, 30, 30), and (30, 15, 30) and hence the homogenous representation will be

 0 0 0 1   30 0 0 1 30 0 30 1    0 0 30 1  0 30 0 1 M    30 30 0 1 30 30 15 1   15 30 30 1  0 30 30 1   30 15 30 1

FRONT VIEW

3-45

To create the front view, the part needs to project onto XY plane and by taking only the x and y coordinate, the front view can be formed.

 0 0 0 1   30 0 0 1 30 0 30 1    0 0 30 11 0 0 0  0 30 0 10 1 0 0 M *     30 30 0 10 0 0 0   30 30 15 1 0 0 0 1    15 30 30 1  0 30 30 1   30 15 30 1  0 0 0 1   30 0 0 1 30 0 0 1    0 0 0 1  0 30 0 1    30 30 0 1 30 30 0 1   15 30 0 1  0 30 0 1   30 15 0 1

TOP VIEW

To create the top view, rotation is carried along the X axis by 90o. The rotation causes the plane ZX to be mapped onto plane XY. Then, 3D part is projected onto XY plane.

Finally, translation with x = 0, y = 70, and z = 0

3-46

 0 0 0 1   30 0 0 1 30 0 30 1    0 0 30 11 0 0 01 0 0 01 0 0 0  0 30 0 10 cos90o sin 90o 00 1 0 00 1 0 0 *     M    o o 30 30 0 10  sin 90 cos90 00 0 0 00 0 1 0     30 30 15 1 0 0 0 1 0 0 0 1 0 70 0 1      15 30 30 1  0 30 30 1   30 15 30 1  0 70 0 1   30 70 0 1 30 40 0 1    0 40 0 1  0 70 0 1    30 70 0 1 30 55 0 1   15 40 0 1  0 40 0 1   30 40 0 1

SIDE VIEW

To create the side view, the part must be rotated by -90o along Y axis prior applying the projection of the 3D part onto the XY plane. Finally, translation by x = 70 is done to position the side view.

3-47

 0 0 0 1   30 0 0 1 30 0 30 1   o o  0 0 30 1cos(90 ) 0  sin( 90 ) 01 0 0 0 1 0 0 0      0 30 0 1 0 1 0 0 0 1 0 0 0 1 0 0 M *          o o 30 30 0 1sin( 90 ) 0 cos(90 ) 00 0 0 0 0 0 1 0     30 30 15 1 0 0 0 1 0 0 0 1 70 0 0 1      15 30 30 1  0 30 30 1   30 15 30 1 70 0 0 1   70 0 0 1 40 0 0 1   40 0 0 1 70 30 0 1    70 30 0 1 55 30 0 1   40 30 0 1 40 30 0 1   40 15 0 1

Table 3.3 shows the orthographic projection of each vertex on each view

Vertex Front Top Side

(0, 0, 0) (0, 0) (0, 70) (70, 0)

(30, 0, 0) (30, 0) (30, 70) (70, 0)

(30, 0, 30) (30, 0) (30, 40) (40, 0)

(0, 0, 30) (0, 0) (0, 40) (40, 0)

(0, 30, 0) (0, 30) (0, 70) (70, 30)

(30, 30, 0) (30, 30) (30, 70) (70, 30)

(30, 30, 15) (30, 30) (30, 55) (55, 30)

(15, 30, 30) (15, 30) (15, 40) (40, 30)

3-48

(0, 30, 30) (0, 30) (0, 40) (40, 30)

(30, 15, 30) (30, 15) (30, 40) (40, 15)

3.5.2 Axometric Projection

Axometric project will display the model in 3D on 2D projected plane. It is also one of the parallel perspective projections. Unlike the orthographic projection, it projects the true length of the object, the axometric projection may project a shorten projection of the objects. To create the axometric, the view point must be at angle a on plane

XY and angle b from plane XY as shown in Figure 3.20.

Figure 3.20 Angle a and b to create axometric projection

Based on view point, to create the axometric projection on graphic screen, it requires three transformation matrices, which are as follows:

i) Rotate the model at angle a on Y axis,

ii) Rotate the model at angle b on X axis, 3-49

iii) Project the model to plane XY

Therefore the compound transformation matrix axometric projection will be as the following:

A R3DY R3D X OZX  cos 0  sin  01 0 0 01 0 0 0  0 1 0 00 cos sin  00 1 0 0 …(3.86) A     sin  0 cos 00  sin  cos 00 0 0 0      0 0 0 10 0 0 10 0 0 1

Based on the angle a and b, the axometric projections can be further classified as isometric, dimetric or trimetric projection and their properties are as follows:

Isometric projection: when all the axes have been shorten at specific scale.

Dimetric projection: two of the axes have been shorten at the same scale.

Trimetric: when all the axes have been shorten at different scale.

In the following, it will discuss the manipulation of angle a and b to create these projections.

Isometric Projection

Figure 3.21 shows a cube has been projected into isometric projection. To create an equal angle  between axes and horizontal line on the right and left sides, the model must rotate by 45o about Y axis (angle a). However, angle b from the plane XY will determine the angle  Both angle b and  are governed by h and w, and the equations for angle b and  are as follows:

3-50

Figure 3.21 Basic isometric projection

 h    sin 1   w 

 h    tan 1   w 

In the case of isometric projection for engineering drawing, the w is longer by

3 to the h. Based on the above equations, angle  should be 30o, and angle b is

35.26o. In all, for isometric projection, angle a is 45o, angle b is 35.26o, and angle  is 30o. Figure 3.22 show the possible isometric projections and the angle of a, b, and

.

3-51

Figure 3.22 Possible isometric projection with angle a, b, and 

Example 3.8

Calculate the vertices of box with 4 unit x 4 unit x 2 unit when the box is projected using isometric projection.

Solution

The homogeneous representation of the box is

0 0 0 1   0 0 2 1 4 0 0 1   4 0 2 1 K   4 4 0 1   4 4 2 1 0 4 0 1   0 4 2 1

To generate the isometric projection,  is 45o, and  is 35.26o. Therefore the transformation matrix will be

A R3DY R3DX OZX 

3-52

0.71 0.41 0 0  0 0.82 0 0 0    0.71  0.41 0 0    0 0 0 1

Therefore, the vertices of the isometric projection are

0 0 0 1   0 0 2 1 4 0 0 10.71 0.41 0 0   4 0 2 1  0 0.82 0 0 K *     4 4 0 10.71  0.41 0 0    4 4 2 1 0 0 0 1 0 4 0 1   0 4 2 1

 0 0 0 1   1.42  0.82 0 1 2.83 1.63 0 1   4.24 0.82 0 1 K *    2.83 4.9 0 1   4.24 4.08 0 1  0 3.27 0 1   1.42 2.45 2 1

Figure 3.24 shows the isometric projection of the box,

Figure 3.24 Isometric Projection of the box

3-53

Length along X axis:

Line from (0, 0, 0) and (4, 0, 0) will be transformed to (0, 0) and (2.83, 1.63),

therefore true length 4 will become 3.27.

Length along Y axis:

Line from (0, 0, 0) and (0, 4, 0) will be transformed to (0, 0) and (0, 3.27),

therefore true length 4 will become 3.27.

Length along Z axis

Line from (0, 0, 0) and (0, 0, 2) will be transformed to (0, 0) and (1.42, -0.82),

therefore true length 2 will become 1.64

Dimetric Projection

Isometric projection will make the axes to be shorten at the same scale. Howeer, when two of the axes have been shorten at different scale from the other axis, it projects into a projection that is called as dimetric. More frequent, the x axis will be scaled differently and this causes the projection is not symmetric. Therefore, the rotation angle a should be larger than 45o. Figure 3.25 show the possible dimetric projections and the angle of a, b, and .

3-54

Figure 3.25 Possible dimetric projection with angle a, b, and 

Dimetric projection will display the model is more realistic manner than isometric projection.

Example 3.9

Calculate the transformed vertices of the box in example 3.8 i)  is set to 50o, 60o, 70o, 80o and  is 24o.

3-55

ii)  is 70o, and  is set to 40o, 30o, 20o, 10o

Solution (a)

Based on equation 3.86, by varying the  and set  = 24o, the resultant vertices are shown in Table 3.4.

Table 3.4 Vertices for various with  = 24o

Vertices = 50o  = 60o  = 70o  = 80o

(0, 0, 0) (0,0) (0, 0) (0, 0) (0, 0)

(0, 0, 2) (1.532, -0.499) (1.732, -0.388) (1.879, -0.266) (1.97, -0.135)

(4, 0, 0) (2.571, 1.190) (2, 1.346) (1.386, 1.46) (0.695, 1.530)

(4, 0, 2) (4.103, 0.691) (3.732, 0,957) (3.247, 1.194) (2.664, 1.395)

(4, 4, 0) (2.571, 4.876) (2, 5.031) (1.368, 5.146) (0.695, 5.216)

(4, 4, 2) (4.103, 4.377) (3.732, 4.643) (3.247, 4.880) (2.664, 5.081)

(0, 4, 0) (0, 3.686) (0, 3.686) (0, 3.686) (0, 3.686)

(0, 4, 2) (1.532, 3.187) (1.732, 3.297) (1.879, 3.420) (1.97, 3.551)

The dimetric projections based on the various angle  are shown in Figure 3.26.

3-56

Figure 3.26 The dimetric projections of various 

Solution (b)

Similarly, equation 3.86 is used, by setting  = 70o and varying the , the resultant vertices are shown in Table 3.5. Figure 3.27 shows each dimetric projection.

Table 3.5 Vertices for various with  = 70o

Vertices = 40o  = 30o  = 20o  = 10o

(0, 0, 0) (0,0) (0, 0) (0, 0) (0, 0)

(0, 0, 2) (1.879, -0.422) (1.879, -0.327) (1.879, -0.233) (1.879, -0.113)

(4, 0, 0) (1.368, 2.319) (1.368, 1.798) (1.368, 1.227) (1.368, 0.622)

(4, 0, 2) (3.247, 1.897) (3.247, 1.471) (3.247, 1.003) (3.247, 0.509)

(4, 4, 0) (1.368, 5.467) (1.368, 5.311) (1.368, 5.008) (1.368, 4.567)

3-57

(4, 4, 2) (3.247, 5.045) (3.247, 4.983) (3.247, 4.784) (3.247, 4.454)

(0, 4, 0) (0, 3.148) (0, 3.513) (0, 3.781) (0, 3.945)

(0, 4, 2) (1.879, 2.726) (1.879, 3.186) (1.879, 3.558) (1.879, 3.832)

Figure 3.27 The dimetric projections of various 

3.6 APPLICATION OF TRANSFORMATION

In addition the application of transformation on the management of CAD entities, transformation can also have other applications. Two of the applications are animation and modeling. Section 3.6.1 will discuss the application of transformation in animation and Section 3.6.2 will discuss the application on modeling purposes.

3.6.1 Animation

Animation is a process displaying a movement that is created by a series of picture or frame. Since animation is directly related to movement, transformation matrix can be

3-58

applied to create the animation. In the following it demonstrates the movement of the a car according the specified path as shown in Figure 3.28. The vehicle will brake until it stops before turning to the right and then the vehicle takes the corners at the same time accelerates. Finally the vehicle will continue to accelerate to reach the desire velocity and the vehicle will travel at the constant velocity.

Figure 3.28 Animation of vehicle according to specified path

Based on the travelling of the vehicle, the path can be divided into four sections.

The sections are straight vertical path during braking, quarter circle path during turning to the right, straight path during accelerating after taking the corner, and finally straight path during travelling at the constant velocity. The initial homogenous representation of the path will be the vertices at the starting point for each path and the application of the transformation matrices will be based on the path and the position of the vehicle based on the time using dynamic of motion. Example 3.10 will demonstrate further to calculate the vertices for the first and the second path.

Example 3.10

The first path in Figure 3.28 is 75 m which the vehicle will brake to stop from initial velocity of 10 m/s. The vehicle will then accelerate to reach 3 m/s at the end of path 2

3-59

based the path generated by radius of the quarter circle of 4.5 m. Then, the vehicle will accelerate to 10 m/s within 30 m and finally travel constantly at 10 m/s for the rest of the journey which in the example for another 50 m.

Solution

Assume the vehicle is represented as a single point. Therefore the homogenous representation of the vehicle will be

V x y 1

First path from A and B

The initial position of the vehicle will be

Vp1  0 0 1

The time taken for the vehicle to stop from initial velocity of 20 m/s will be based on the v  u  at at  v  u s  ut  0.5at 2 s  t(u  0.5at)

s  tmax (u  0.5(v  u)) s t  max 0.5(u  v)

When sy = 75 m, uy = 10 m/s, and vy = 0, t = 15 sec.

If the position of the vehicle is calculated based on every second, s(t) for t = 0 to 15 sec will be

3-60

(v  u) ay  tmax 2 sx (t)  uxt  0.5axt 2 sy (t)  uyt  0.5ayt

Therefore, the translation the vehicle will be

* [Vp1]  [V ][T ]  1 0 0    [0 0 1] 0 1 0   Sx (t) S y (t) 1

When t = 0 to 15 is inserted to the equation, the translation of the vehicle will be in

Table 3.6

Table 3.6 Position of the vehicle at time t

Time (sec) Distance s(t) Time (sec) Distance s(t) m

0 (0, 0) 8 (0, 58.67)

1 (0, 9.67) 9 (0, 63)

2 (0, 18.67) 10 (0, 66.67)

3 (0, 27) 11 (0, 69.67)

4 (0, 34.67) 12 (0, 72)

5 (0, 41.67) 13 (0, 73.67)

6 (0, 48) 14 (0, 74.67)

3-61

7 (0, 53.67) 15 (0, 75)

Second path from B to C

For the second path, the starting point is at the point where the vehicle stops which is

(0, 75) and the time at point B will be set to 0.

Similar, approach as path is used here except the motion will be in angular.

 tmax  0.5(o  1)

where = /2, o = 0 and V 3     0.67 rad / s 1 r 4.5

Hence, the time taken to the vehicle to complete path 2 is

 tmax  = 4.71 sec 0.5(o  )

Therefore, (t) will be

2  (t)  ot  0.5t

The rotation transformation will be (negative angle due to the clockwise direction)

 cos((t)) sin( (t)) 0 R   sin( (t)) cos((t)) 0 2D    0 0 1

The initial position of the vehicle for Path 2 is

Vp2  0 75 1

3-62

The center of rotation will be at (4.5, 75). Since the center of rotation is not the origin, the

 1 0 0 cos((t)) sin( (t)) 0 1 0 0 *     V p 2  0 75 1 0 1 0 sin( (t)) cos((t)) 0 0 1 0  4.5  75 1 0 0 14.5 75 1

By inserting the time, the position of the vehicle at the specified is listed in Table 3.7.

Table 3.7 Position of the vehicle at the specified time (Path 2)

Time (s) 0 1 2 3 4 4.71

Position (0, 75) (0.01, 75.32 ) (0.18, 76.26) (0.88, 77.68) (2.59, 79.07) (4.50, 79.50)

Path 3

Similar approach as in calculating the position of vehicle for Path 2, the initial known variables will be

Distance travel s = 30 m

Initial velocity u = 3 m/s

Final velocity v = 10 m/s

Homogeneous representation of the vehicle: Vp3  4.5 79.5 1

Based on these variables, time taken to travel will be 4.62 sec (tmax)

Therefore, the position of the vehicle with respect to time will be in Table 3.8

Table 3.8 Position of the vehicle at the specified time (Path 3)

Time (s) 0 1 2 3 4 4.62

3-63

Position (4.5, 79.5) (8.26, 79.5 ) (13.53, 79.5) (20.33, 79.5) (28.63, 79.5) (34.5, 79.50)

Path 4

The known variables for Path 4

Distance travel s = 50 m

Initial velocity u = 10 m/s

Final velocity v = 10 m/s

Homogeneous representation of the vehicle: Vp3  34.5 79.5 1

Based on these variables, time taken to travel will be 5 sec (tmax)

Therefore, the position of the vehicle with respect to time will be in Table 3.9

Table 3.9 Position of the vehicle at the specified time (Path 4)

Time (s) 0 1 2 3 4 4.62

Position (34.5, 79.5) (44.5, 79.5 ) (54.5, 79.5) (64.5, 79.5) (74.5, 79.5) (80.7, 79.5)

Figure 3.29 shows the vertices on the path.

3-64

Figure 3.29 Vertices of the path

3.6.2 Modeling purposes

For the purposes of modelling, it is easier to model the part separately. This is because it is common to have one reference point on the part and all the dimension will be referred to this reference. Therefore, it will be easier, the origin of axis (0, 0, 0) is regarded as the reference point. After the part is drawn, then transformation matrices will be applied to the part to position the part on the intended place.

Figure 3.29 shows application of the transformation to model robotic arm. The robotic comprises Arm 1, Arm 2, and Gripper. To ease the modelling process, each part will be modelled separately using the origin (0, 0) as the reference point as shown in Figure 3.29a. When the robotic arm is assembled, it should be assembled as shown in Figure 3.29b. Therefore, the transformation matrices are used to assemble the robotic arms.

Figure 3.29 Application of transformation on robotic modelling

To model Arm 1, Arm 1 will be rotated by 45o

3-65

 cos(45o ) sin( 45o ) 0 *  o O  Varm1  Varm1 sin( 45 ) cos(45 ) 0    0 0 1

To model Arm 2, the arm must be rotated by 20o counter clock wise direction and followed with translation to the other end of arm1.

 cos(20o ) sin( 20o ) 0 1 0 0 *  o o   V arm2  V  sin( 20 ) cos(20 ) 0 0 1 0    arm2      o o  0 0 1L1cos(45 ) L1sin( 45 ) 1

To model the gripper, the gripper must be rotated 30o clock wise direction and followed with translation to the other end of Arm 2.

 cos(30o ) sin( 30o ) 0 1 0 0   V *  V  sin( 30o ) cos(30o ) 0  0 1 0  gripper  gripper     o o o o  0 0 1L1cos(45 )  L2cos(20 ) L1sin( 45 )  L2sin( 20 ) 1

Example 3.11

The arms are modelled using API function that is able to create a cube of 1 x 1 x 1.

Therefore, the task is to model the upper and lower arms to be at intended position shown in Figure 3.30 from the basic cube of 1 x 1 x 1. The size of the lower arm is 2 x

2 x 20 and upper arm is 2 x 2 x 5.

3-66

Figure 3.30 Simplified robotic arm

Solution

The steps to model the lower and upper arm are as the following

Step 1: Scaling to lower and upper (Figure 3.31a)

Since the arm is built from a cube 1 x 1 x 1, scaling of the cube accordingly will create the lower and upper arm.

The scaling of lower arm

2 0 0 0 0 2 0 0 1*   Larm  L  arm 0 0 20 0   0 0 0 1

The scaling of the upper arm

2 0 0 0 0 2 0 0 1*   U arm  U  arm 0 0 5 0   0 0 0 1

Step 2: Translate the upper arm at the end of the lower arm (Figure 3.31b)

1 0 0 0 0 1 0 0 2* 1*   U arm  U  arm 0 0 1 0   0 0 20 1

Step 3: Rotate lower and upper arm along –ve Y axis by 60o (Figure 3.3c)

The transformation for the lower arm.

3-67

cos(30o ) 0 sin( 60o ) 0   0 1 0 0 L3*  L1*   arm arm sin( 30o ) 0 cos(30o ) 0    0 0 0 1

The transformation for the upper arm

 1 0 0 0 cos(30o ) 0 sin( 30o ) 0 1 0 0 0      0 1 0 0 0 1 0 0 0 1 0 0 U 3*  U 2*      arm arm  0 0 1 0 sin( 30o ) 0 cos(30o ) 0 0 0 1 0  o o    o o   20cos(60 ) 0  20sin( 60 ) 1  0 0 0 120cos(60 ) 0 20sin( 60 ) 1

Step 4: Rotate upper arm along +ve Y axis by 10o (Figure 3.3d)

The center rotation is at the end of the lower arm which is (20 cos(60o), 20 sin(60o)).

Therefore, translation must be applied before and after the rotation matrix.

 1 0 0 0 cos(10o ) 0 sin(10o ) 0 1 0 0 0      0 1 0 0 0 1 0 0 0 1 0 0 U 4*  U 3*      arm arm  0 0 1 0 sin(10o ) 0 cos(10o ) 0 0 0 1 0  o o    o o   20cos(60 ) 0  20sin( 60 ) 1  0 0 0 120cos(60 ) 0 20sin( 60 ) 1

Step 5: Rotate the lower and upper arm by 15o along +ve Z axis (Figure 3.31e)

The transformation for the lower arm.

cos(15o ) sin(15o ) 0 0   sin(15o ) cos(15o ) 0 0 L5*  L3*   arm arm  0 0 1 0    0 0 0 1

The transformation for the upper arm.

 1 0 0 0 cos(15o ) sin(15o ) 0 0 1 0 0 0    o o   0 1 0 0 sin(15 ) cos(15 ) 0 0 0 1 0 0 U 5*  U 4*      arm arm  0 0 1 0  0 0 1 0 0 0 1 0  o o    o o   20cos(60 ) 0  20sin( 60 ) 1  0 0 0 120cos(60 ) 0 20sin( 60 ) 1

3-68

Figure 3.31 Steps to model the robotic arm

 Note: there are other possible compounded transformation to generate similar

position of the arms.

3.6.3 Kinematic of the open loop mechanism

The transformation is also applicable to the kinematic study of the mechanism especially the open loop mechanism. The main interest in the kinematic study is the position of the arm. The movement of the arm depends on the joint types. Figure 3.32 shows the types of joint available can be used to build a mechanism.

3-69

Figure 3.32 Types of joints

The prismatic joint will only allow the translation, whilst the revolutional joint will only allow the linkage at the center of the joint. Cylindrical joint will allow translation and revolution. The translation will be along the axis of the cylindrical joint and the revolution will be rotated at the center of the cylinder. Finally spherical joint will allow rotational movement in all direction X, Y, Z direction.

Figure 3.33 shows one example of robotic arms. The arms comprises all revolutional joints except at the gripper which is prismatic. Even with the combination of revolutional joints of various axes will develop a complex movement.

Figure 3.33 Sample of robotic arm

3-70

Example 3.12

Figure 3.34 shows one robotic arms. Develop the matrices that will calculate the position of point O based on angle , , and  and the length of each arms L1, L2, and

L3.

Figure 3.34 Robotic arm with three revolutional joints

Solution

To calculate the position of O, it relies on the position of C, B, and A. Therefore, position of A must be calculated first, then follows with the calculating the position of

B and follow with position C.

Assuming all the linkages are positioned horizontally along the X axis, therefore, the initial homogenous representation of linkages are

Linkage 1: L1  L1 0 1

Linkage 2: L2  L2 0 1

Linkage 3: L3  L3 0 1

Calculating position B

3-71

 cos sin  0 B B 1  L1 0 1  sin  cos 0  x y      0 0 1

Calculating position B

 cos( ) sin(  ) 0 1 0 0   C C 1  L2 0 1  sin(  ) cos( ) 0 0 1 0  x y          0 0 1Bx By 1

Therefore, position O

 cos( ) sin(  ) 0 1 0 0   O O 1  L3 0 1  sin(  ) cos( ) 0 0 1 0  x y          0 0 1Cx C y 1

Therefore, the generic equation for open loop mechanism will be

 1 0 0 x' y' 1  L 0 1   0 1 0  i i   i   required    xi1 yi1 1

3-72

CHAPTER 5

NEUTRAL FILE

Transfer of CAD files from one platform to another is common and even the model has to be transferred to another format to allow the model to be used for downstream activities. This transfer of part becomes possible with the neutral file.

This chapter will further explore the neutral file to make understanding the capability of the neutral file. It starts will explanation on the neutral file ion Section

5.1. Then, it is followed with the types of neutral files based on standard institutions that are responsible to develop the neutral files and the solid kernel in Section 5.2 and

5.3 respectively. Then, it discusses the neutral files based on the applications in

Section 5.4.

The chapter continues on the steps to comprehend the neutral files in Section

5.5. Then, case studies are carried to investigate what are transferred and lost when

CAD files are transferred through neutral 5.6. Finally, the chapter concludes with some of the remarks on the neutral file in Section 5.7

5.1 WHAT IS NEUTRAL FILE?

The transfer of file between CAD platforms and even for downstream activities becomes requirement. Therefore, when every platform requires specific file, the number of file transfer will be exponentially increases with the number the number of

CAD packages. This is illustrated as in Figure 5.1.

5-1

Figure 5.1 File transfers requirement between CAD packages

Therefore, neutral file is introduced with the aim to reduce the number of file transfer interfaces between CAD packages. Figure 5.2 shows the ideally structure of neutral file. Ideally, there will be one neutral file that will act as the interfaces between CAD packages and downstream activities.

Figure 5.2 Ideal structure to interface between CAD packages.

Despite the fact, it should be one neutral file that acts as the file transfer between platforms and applications, in reality, there are a number of neutral files. The neutral files can be classified into three groups based on their developer. The developers of the neutral files are standard institution, CAD packages or solid kernel, and specific applications. In the following section, it will discuss each type.

5-2

5.2 STANDARD INSTITUTION

The need to have one standard file transfer is the reason for the establishment of standard institution to deal with file transfer between CAD packages. It started when

General Electric challenged CAD package developer to set up one standard body at one conference in 1979. Hence, Interim Graphic Exchange Standard project under the responsibility of American National Standards Institute (ANSI) was established after the conference. This project produces standard that is called as Initial Graphic

Exchange Standard (IGES). In 1980, the team released its first draft after two critical reviews and adopted to ANSI standard in 1981.

However, IGES was developed focused on the exchange of geometric data between CAD packages. However, as the CAD packages includes the entire life cycle of a product, Standard for the exchange of Product Model Data (STEP) was developed by International Standard Organization (ISO) under ISO 10303 standard since 1984. Ten year later, in 1984 the first parts of the standard were established.

In the following, it will comprehend the content of the IGES and STEP file.

5.2.1 IGES

IGES file is denoted by *.igs file extension and it is written using standard

ASCII code. Therefore, IGES neutral file can be read and even edited by most of the text editor. Figure 5.3 shows portion of IGES file. This file is created from line from

(10,10) to (5,7) and circle with radius 2 and center point (7,2) are drawn in AutoCAD.

The following shows sample of IGES file.

Autodesk DirectConnect version 7.0.27.0 ---- IGES version 5.3 S 1 1H,,1H;, 7HUnknown,55HC:\line circle.igs,31HAutodesk DirectConnect G 1 7.0.27.0,8H7.0.27.0,32,38,6,308,15,7HUnknown,1.0,1,2HIN,1,0.01,15H G 2 20131212.153341,0.001,10.0,9Hjamaltaib,7HUnknown,11,0,15H2013 G 3 1212.153341; G 4

5-3

314 1 0 0 0 0 0 000000200D 1 314 0 0 1 0 0D 2 124 2 0 1 1 0 0 000000000D 3 124 0 0 1 0 AcDbCirc 0D 4 100 3 0 1 1 0 3 000000000D 5 100 0 0 1 0 AcDbCirc 0D 6 110 4 0 1 1 0 0 000000000D 7 110 0 0 1 0 AcDbLine 0D 8 314,0.0,0.0,0.0,6HGlobal; 1P 1 124,1.0,0.0,0.0,7.0,0.0,1.0,0.0,2.0,0.0,0.0,1.0,0.0; 3P 2 100,0.0,0.0,0.0,2.0,0.0,2.0,0.0; 5P 3 110,10.0,10.0,0.0,5.0,7.0,0.0; 7P 4 S 1G 4D 8P 4 T 1

IGES file is formatted according to the line and each line will end with code to section the information belonged to. In all, there are five sections which are Start,

Global, Directory Entry, Parameter Data, and Terminate. To differentiate between the sections, code S, G, D, P, and T for Start, Global, Directory Entry, Parameter Data, and Terminate section respectively will be assigned to each line to show the line belongs to respective sections.

Code S at the end the line shows the Start section. It contains the names of the source and receiving CAD systems. In this example, the conversion is carried out by

Autodesk DirectConnect version 7.0.27.0 and the file is transferred to IGES version

5.3. If the file fails to be converted, one of the possibility is that the converter or IGES version is compatible.

Then it is followed with the Global section that is coded as G at the end of the line. Global section provides the information of the file parameters such as in the following:

Parameter Delimiter Character = "," System ID = "Autodesk DirectConnect 7.0.27.0" Record Delimiter Character = ";" Pre-processor Version = "7.0 27.0" Product ID from Sender = "{Unknown}" Number of Bits for Integers = 32 File Name = "line circle.igs" Single Precision Magnitude = 38

5-4

Single Precision Significance = 6 Approximate Maximum Coordinate = 10.00000 Double Precision Magnitude = 308 Name of Author = " jamaltaib" Double Precision Significance = 15

Product ID for Receiver = "{Unknown}"

Model Space Scale = 1.00000 7HUnknown, Unit Flag = 1 - Inches Author's Organization = "{Unknown}" Units = "INCH" IGES Version Number = 11 Maximum Number of Line Weights = 1 Size of Maximum Line Width = 0.01 Drafting Standard Code = 0 Date & Time Stamp = "20131212.153341" Minimum User-intended Resolution = 0.001 Model Creation/Change Date =

"20131212.153341"

All the file parameters are placed in sequence with comma as the separator. As far as part is concerned, this Global section provides the setting for the part such as units and precision together the parameters that are set to the files such as author, time, etc.

After the Global Section, it is followed by Directory Entry section. Directory

Entry section is coded by letter D at the end of the line. The Directory Entry will give the information on the entity type. Two lines will be allocated for each entity and for every line, 10 field is used and total of 20 field will be allocated for each entity. The type of entity is coded as number that will be placed in the first field for each line.

Some of the number coded entity are as the following

100 Circular arc

108 Plane

110 Line

116 point

124 Transformation matrix

For each entity, it will have 20 fields which as the following:

5-5

Line1 Field 1: Entity type (100 = Line) Field 2: Pointer will refer to parameter data line (3 refer to line 3 in parameter data) Field 3: Pointer to D section (default 0) Field 4: Line font pattern Field 5: Level Field 6: Pointer to section D line of view entity Field 7: Pointer to section D entry of transformation matrix (Line 3: 124) Field 8: Pointer to section D entry of label (not applicable line) Field 9: Status. 4x2-digit values to form 8-digit number, no spaces. Field 10: Line number within D section. (5, the first line the number must be odd) Line 2 Field 11: Entity type Field 12: Line weight 0 to max Field 13: Color number: 0-8. Negative number refers to a Color Definition Field 14: Number of lines in the corresponding Parameter Data for this entity Field 15: Form number for entities having more than one definition Field 16: Not used Field 17: Not used Field 18: Entity label, up to 8 chars. Field 19: Entity subscript number Field 20: Line number within D section (6, the second line must be an even number)

The information of Directory Entry data will be accompanied with the respective entity in Parameter Data. The parameter data section is identified by the letter at the second field before the end of the line. The first field will be entity type number and follows comma delimeter and final for each parameter data section will end semi-colon delimeter. The number field depends on the entity type. For example, circle will have 10 parameters which are entity type, x, y, and z of center point, radius and the transformation matric, whilst line will have seven parameters, entity number follows the x, y, and z of the start and end point. Parameter data section will be followed with last line with termination line. This indicates the end of the file.

5-6

In all, it can be said that the IGES is quite difficult to comprehend. The entities from IGES file in Figure 5.3 comprises three entities and the IGES becomes more complex when the part is solid model.

5.2.2 STEP (Standard for the Exchange of Product Model Data)

STEP is the acronym for Standard for the Exchange of Product Model Data.

Currently, there is a number of neutral files such as IGES, SET, and VDAFS, therefore, International Standard Organization has decide to have Standard Exchange

Protocol (STEP). The aim of STEP is to allow exchange of data between different platform without human intervention and integrate of data from different platforms.

IN fact, STEP is a computer interpretable representation of the data.

Due to vast applications of CAD platform, STEP is divided its protocol according to its applications which is called application protocol (AP). Each AP will be have number coded.

Following is the list of available APs.

AP 201: Explicit draughting. Simple 2D drawing geometry related to a product. No

association, no assembly hierarchy.

AP 202, Associative draughting. 2D/3D drawing with association, but no product

structure.

AP 203, Configuration controlled 3D designs of mechanical parts and assemblies.

AP 204, Mechanical design using boundary representation

AP 207, Sheet metal die planning and design

AP 209, Composite and metallic structural analysis and related design

5-7

AP 214, Core data for automotive mechanical design processes

AP 235, Materials information for the design and verification of products

AP 236, Furniture product data and project data

AP 242, Managed model based 3d engineering (under development)

AP 210, Electronic assembly, interconnect and packaging design. The most complex

and sophisticated STEP AP.

AP 212, Electrotechnical design and installation.

AP 227, Plant spatial configuration

AP 215, Ship arrangement

AP 216, Ship moulded forms

AP 218, Ship structures

AP 225, Building elements using explicit shape representation

AP 232, Technical data packaging core information and exchange

AP 233, Systems engineering data representation

AP 237, Fluid dynamics has been cancelled and the functionality included in AP 209

AP 219, Dimensional inspection information exchange

AP 223, Exchange of design and manufacturing product information for cast parts

AP 224, Mechanical product definition for process plans using machining features

AP 238 - Application interpreted model for computer numeric controllers

AP 240, Process plans for machined products

AP 239, Product life cycle support

5-8

AP 221, Functional data and schematic representation of process plants

The STEP file is formatted according to International Standard Organization

ISO 10303-21. STEP will have *.step or *.stp extension and the file is formatted according to ASCII code. Therefore, any text editor must be able to read and edit the files.

In every STEP file, it starts with a statement of ‘ISO-10303-21;’ and ends with a statement of ‘END-ISO-10303-21;’ All the information are stored in between these statements. The information can be grouped into two, namely Header and Data. For each section, it will start with the section name (such as ‘HEADER;’ or ‘DATA;’) and end the section with ‘ENDSEC;’.

In the following, it shows sample of step file.

ISO-10303-21; HEADER; FILE_DESCRIPTION (( 'STEP AP203' ), '1' ); FILE_NAME ('2 step 203 fea.STEP', '2014-03-11T07:09:14', ( '' ), ( '' ), 'SwSTEP 2.0', 'SolidWorks 2013', '' ); FILE_SCHEMA (( 'CONFIG_CONTROL_DESIGN' )); ENDSEC; DATA; #1 = AXIS2_PLACEMENT_3D ( 'NONE', #285, #24, #254 ) ; #2 = LINE ( 'NONE', #253, #265 ) ; #3 = LINE ( 'NONE', #264, #29 ) ; #4 = DIRECTION ( 'NONE', ( 1.000000000000000000, 0.0000000000000000000, 0.0000000000000000000 ) ) ; … #418 = PRODUCT_CONTEXT ( 'NONE', #94, 'mechanical' ) ; #419 = DIMENSIONAL_EXPONENTS ( 1.000000000000000000, 0.0000000000000000000, 0.0000000000000000000, 0.0000000000000000000, 0.0000000000000000000, 0.0000000000000000000, 0.0000000000000000000 ) ; #420 = ORIENTED_EDGE ( 'NONE', *, *, #23, .F. ) ; #421 = ORIENTED_EDGE ( 'NONE', *, *, #28, .T. ) ; ENDSEC; END-ISO-10303-21;

5-9

The Header section comprises the information on the file. The information will be as the following;

File description: STEP AP203

Implementation level: 1

File name: ‘2 step 203 fea.STEP

Time: 2014-03-11T07: 09:14

Author: (' '),

Organization: (' '),

Preprocessor version: 'SwSTEP 2.0'

Originating_system: 'Solid Work 2013',

Authorization: (' ');

The Header section will give information on the files such as file name, time and date file creation. It also gives information on the system such as STEP pre- processor version as well as the CAD platform where the file is created.

After Header section, Data section will follow. The data section will start with

‘DATA;’ and end with word ‘ENDSEC;’. This data section is formatted as such it starts with Instance name. Instance name is formatted with ‘#’ and number.

All the geometrical properties and attributes of the entity will be stored in this section. The data are stored based using the linkages of the lines.

#2 = LINE ( 'NONE', #253, #265 ) ;

As such in line #2 in data section is belonged to line. The line is not assigned to any specific name that is mentioned as ‘NONE’. Line #253 and #265 are the lines

5-10 that have further information on the lines. Visiting all the related lines, the attributes and geometrical properties of the entities can be retrieved.

5.3 SOLID KERNEL

Neutral files are also developed by the developer of the solid kernel such as ACIS and

Parasolid. In the following, it will discuss the neutral file developed by ACIS solid kernel.

ACIS (Alan, Charles, Ian System)

ACIS is acronym to Alan, Charles, Ian System. ACIS file is indicated in .sat file name and it is formatted according to ASCII code. Therefore, the file is readable by any text editor that can read ASCII code.

ACIS has reserved a number of characters to indicate the information. The reserved characters are

$ : indicates a pointer definition in format of number. The number in fact

indicates the lines that will have related information. -1 ($-1) will be set a null

pointer definition.

# : terminates an entity record. This symbol indicates end of the record of the

specified lin.

@ : starts of string record. Since some of the information are stored in string

format, any string format information will be indicated by @ and followed

with the information such @ part1.

Following shows sample of ACIS file.

5-11

2200 0 1 0 15 SolidWorks 2014 12 ACIS 22.0 NT 24 Tue Dec 09 11:14:12 2014 1 9.9999999999999995e-007 1e-010 -0 body $1 -1 -1 $-1 $2 $-1 $-1 F # -1 name_attrib-gen-attrib $-1 -1 $-1 $-1 $0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 @5 Part1 # -2 lump $3 -1 -1 $-1 $-1 $4 $0 F # -3 rgb_color-st-attrib $-1 -1 $-1 $-1 $2 2 1 2 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0.792156862745098 0.81960784313725488 0.93333333333333335 # -4 shell $-1 -1 -1 $-1 $-1 $-1 $5 $-1 $2 F # -5 face $6 -1 -1 $-1 $7 $8 $4 $-1 $9 reversed single F T 0 1.5424561250046767 - 3.1415926535897931 0 # … -132 point $-1 -1 -1 $-1 150 0 0 # -133 straight-curve $-1 -1 -1 $-1 150 30 0 -0 -1000 -0 I I # -134 straight-curve $-1 -1 -1 $-1 150 30 -90 -0 -1000 -0 I I # End-of-ACIS-data

ACIS file ends the statement End-of-ACIS-data.

The first three lines is the header section. The following is sample of the header section

2200 0 1 0 15 SolidWorks 2014 12 ACIS 22.0 NT 24 Tue Dec 09 11:14:12 2014 1 9.9999999999999995e-007 1e-010

First line:

First Integer: An encoded version number (22.00).

Second Integer: The total number of saved data records, or zero. If zero, then an

end mark is required.

Third Integer: A count of the number of entities in the original entity list that

were saved to the part file.

Forth Integer: The least significant bit of this number is used to indicate

whether or not history has been saved in this save file.

5-12

Second line

First Integer: String length for the product string: “15”.

Second String: ID for the product which produced the file: “SolidWorks 2014”.

Third Integer: String length for the ACIS version string: “12”.

Fourth String: ACIS version which produced the file: “ACIS 22.0 NT”.

Fifth Integer: length for the date string: “24”.

Sixth String: Date file produced “Tue Dec 09 11:14:12 2014”.

Third line

First Double: Number of millimeters represented by each unit in the model: “1”

Second Real: The smallest meaningful quantity. For CAD model, it can be

translated as the smallest distance can be drawn “9.9999999999999995e--

007”

Third Real: The ratio of smallest meaningful quantity to the largest meaningful

quantity. “1e-10”

From the fourth line onward until the word “End-of-ACIS-data” is the data section. It comprises the attributes and topological information on the entity.

The first entity record must be body entity and the remaining will be in no particular order. The body record is indexed as 0 sequence number.

Each entity record consists of a sequence number, an entity type identifier, the entity data, and a terminator. Entity type identifier is unique string such body, lump, etc.

-0 body $1 -1 -1 $-1 $2 $-1 $-1 F #

5-13

Therefore the ‘BODY’ data structure will refer to pointer $1, $2

-1 name_attrib-gen-attrib $-1 -1 $-1 $-1 $0 2 1 1 1 1 1 1 1 1 1 1

1 1 1 0 1 1 1 @5 Part1 #

-2 lump $3 -1 -1 $-1 $-1 $4 $0 F #

Line with pointer 1 is name_attrib_gen_attrib which store the transformation of the model. As far as pointer is concerned, it will refer to its parent pointer that is 0.

B-Reps data are also stored in the data section. Body will be the highest hierarchy of data will refer to the next topological data which in the above example, it will refer to pointer 2. Line with pointer 2 is lump. Therefore, lump will refer to pointer 3 and 4 for further data and its parent pointer 0. From the body data, all the B-

Reps data and attributes can be retrieved. The data sections ends with ‘End of Sec’.

5.4 SPECIFIC APPLICATIONS

Neutral files are also been developed for specific applications. In the following, it discusses some of neutral developed using specific application.

5.4.1 Stereo Lithography file format

Stereo Lithography file format has .stl extension. Solid model has been represented as a list of triangulated surface comprises of loop of three vertices. This file format has been widely in rapid prototyping machine and 3D printer.

Following shows the portion of .stl file using ASCII format. solid Part1 litho facet normal -1.000000e+000 0.000000e+000 0.000000e+000 outer loop vertex 0.000000e+000 0.000000e+000 7.500000e+001

5-14

vertex 0.000000e+000 5.000000e+001 7.500000e+001 vertex 0.000000e+000 0.000000e+000 0.000000e+000 endloop endfacet … Endsolid

The level data will be stored and the levels are solid, facet, and loop. The data of each level will end with statement of Endsolid, Endfacet, and EndLoop for the solid, facet, and loop respectively. For every facet data, it starts with the facet normal and follows with the list of loops and for each loop, it will be described as three vertices using

Cartesian Coordinate System.

Figure 5.3 shows the solid part in Figure 5.3a and its stereo lithography representation in Figure 5.3b. shows every face of the part is converted to triangulated facet. The model will have one solid with a number of triangular facets. Each triangular facet comprises one loop with three vertices.

Figure 5.3: (a) solid model and its (b) stereolithography reprsentation

5.4.2 Virtual Reality Modeling Language (VRML)

5-15

VRML has .wrl file extension. This file can be used in World Wide Web to show the solid part with the capability of animation. VRML file will store the shape, appearance, material, transformation, etc. The part is stored as simple shape such as cylinder, box, sphere, etc, or collection of 2D polygons. .

Following shows portion of VRML file.

#VRML V2.0 utf8 Transform { children [ Shape { appearance Appearance { material Material { ambientIntensity 1.000000 … shininess 0.310000 transparency 0.000000 } } geometry IndexedFaceSet { color Color { color [ 0.894118 0.894118 0.894118 ] } coord Coordinate {

… ]

}

5.4.3 VDAFS (Verenung Deutsche Automobilindustrie Flachen

Schnittstelle)

5-16

VDAFS will transfer the CAD data into free surface model for the purposes of automobile industries. The file will have *.vda extension and the file is readable by any ASCII text editor.

The following shows samples of VDAFS file.

SLDWORKS = HEADER / 20 00000001 *********************************************************************** 00000002 VDAFS VERSION : 2.0 00000003 ------SENDER DATA ------00000004 SENDER COMPANY : UNKNOWN 00000005 … SENDING DATE : 12/09/2014 00000010 FILE NAME : part4.vda 00000011 ------PART DATA ------00000012 PROJECT NAME : UNKNOWN 00000013 … DATE EFFECTIVE : 12/09/2014 00000017 ------RECEIVER DATA ------00000018 COMPANY NAME : UNKNOWN 00000019 RECEIVER NAME : UNKNOWN 00000020 *********************************************************************** 00000021 SR1 = SURF / 1, 1, 0.0000000000000000E+00, 1.0000000000000000E+00, 00000022 0.0000000000000000E+00, 1.0000000000000000E+00, 00000023 … FC43 = FACE / SR2, 1, 00000405 4, 00000406 CN34, 0.0000000000000000E+00, 1.0000000000000000E+01, 00000407 CN20, 0.0000000000000000E+00, 1.0000000000000000E+01, 00000408

CN33, -1.0000000000000000E+01, 0.0000000000000000E+00 00000410 SLDWORKS = END 00000441

There are two sections in the VDAFS file. It starts with header file that comprises VDAFS version, sender profile, part data and receiver data. Then, it follows with the data section that consists of geometrical and non-geometrical entity types. The geometrical data are, point, point set, curve, surface curve on surface and face, whilst the non-geometrical data are transformation matrix and list.

5-17

5.4.4 Graphic

CAD model can also be converted to graphic such as bmp, tiff or jpeg format.

Normally, graphical type conversion is used for documentation. The graphic format is basically 2D images of the parts and inserted directly to the documents.

5.5 HOW TO COMPREHEND NUETRAL FILE

Neutral file has been used as input by many researchers to make the developed system to be independent of the any CAD packages. Therefore, it is necessary to understand and comprehend the neutral. Furthermore, the topology and geometry will be studied.

In this book, it is limited to STEP and ACIS.

In this study, a cylinder with the following geometrical properties are used;

i) Radius: 20 mm

ii) Height: 40 mm

iii) Center point of bottom plane: ( 0, 0)

iv) Extrusion direction: + Z axis.

5.5.1 STEP

This is the step file for the above part. Since the focus of the discussion is on the shape data, the lines that contains the information non-shape data are deleted from the file.

5-18

DATA; #2 = PLANE ( 'NONE', #37 ) ; #3 = DIRECTION ( 'NONE', ( 0.00, 0.00, 1.00 ) ) ; #5 = DIRECTION ( 'NONE', ( 1.00, 0.00, -0.00 ) ) ; #6 = CARTESIAN_POINT ( 'NONE', ( 0.00, 0.00, 0.00 ) ) ; #7 = EDGE_CURVE ( 'NONE', #125, #50, #144, .T. ) ; #11 = DIRECTION ( 'NONE', ( -0.00, -0.00, -1.00 ) ) ; #12 = AXIS2_PLACEMENT_3D ( 'NONE', #115, #157, #5 ) ; #14 = CARTESIAN_POINT ( 'NONE', ( 0.00, 0.00, 0.00 ) ) ; #15 = DIRECTION ( 'NONE', ( -1.00, 0.00, 0.00 ) ) ; #16 = DIRECTION ( 'NONE', ( -0.00, -0.00, -1.00 ) ) ; #17 = AXIS2_PLACEMENT_3D ( 'NONE', #6, #3, #113 ) ; #20 = ORIENTED_EDGE ( 'NONE', *, *, #27, .F. ) ; #22 = AXIS2_PLACEMENT_3D ( 'NONE', #66, #121, #78 ) ; #26 = ORIENTED_EDGE ( 'NONE', *, *, #57, .F. ) ; #27 = EDGE_CURVE ( 'NONE', #50, #28, #171, .T. ) ; #28 = VERTEX_POINT ( 'NONE', #156 ) ; #29 = DIRECTION ( 'NONE', ( 0.00, 0.00, 1.00 ) ) ; #32 = CLOSED_SHELL ( 'NONE', ( #81, #155, #143, #79 ) ) ; #33 = CIRCLE ( 'NONE', #17, 20.00 ) ; #34 = CARTESIAN_POINT ( 'NONE', ( 20.00, 2.459E-015, 40.00 ) ) ; #36 = FACE_OUTER_BOUND ( 'NONE', #165, .T. ) ; #37 = AXIS2_PLACEMENT_3D ( 'NONE', #154, #48, #109 ) ; #40 = CARTESIAN_POINT ( 'NONE', ( 0.00, 0.00, 40.00 ) ) ; #43 = CARTESIAN_POINT ( 'NONE', ( -20.00, 0.00, 40.00 ) ) ; #44 = DIRECTION ( 'NONE', ( 0.00, 0.00, 1.00 ) ) ; #47 = ORIENTED_EDGE ( 'NONE', *, *, #7, .F. ) ; #48 = DIRECTION ( 'NONE', ( 0.00, 0.00, 1.00 ) ) ; #50 = VERTEX_POINT ( 'NONE', #83 ) ; #51 = DIRECTION ( 'NONE', ( 0.00, 0.00, 1.00 ) ) ; #52 = VECTOR ( 'NONE', #16, 1000.00 ) ; #53 = EDGE_CURVE ( 'NONE', #28, #50, #33, .T. ) ; #55 = EDGE_LOOP ( 'NONE', ( #170, #20 ) ) ; #56 = CYLINDRICAL_SURFACE ( 'NONE', #22, 20.00 ) ; #57 = EDGE_CURVE ( 'NONE', #163, #125, #93, .T. ) ; #63 = AXIS2_PLACEMENT_3D ( 'NONE', #40, #29, #120 ) ; #64 = ORIENTED_EDGE ( 'NONE', *, *, #102, .T. ) ; #66 = CARTESIAN_POINT ( 'NONE', ( 0.00, 0.00, 40.00 ) ) ; #71 = DIRECTION ( 'NONE', ( 1.00, 0.00, 0.00 ) ) ; #74 = AXIS2_PLACEMENT_3D ( 'NONE', #111, #141, #71 ) ; #78 = DIRECTION ( 'NONE', ( -1.00, 0.00, 0.00 ) ) ; #79 = ADVANCED_FACE ( 'NONE', ( #128 ), #2, .F. ) ;

5-19

#81 = ADVANCED_FACE ( 'NONE', ( #131 ), #56, .T. ) ; #82 = PLANE ( 'NONE', #12 ) ; #83 = CARTESIAN_POINT ( 'NONE', ( 20.00, 2.45E-015, 0.00 ) ) ; #85 = AXIS2_PLACEMENT_3D ( 'NONE', #127, #98, #15 ) ; #86 = SHAPE_DEFINITION_REPRESENTATION ( #107, #167 ) ; #87 = ORIENTED_EDGE ( 'NONE', *, *, #27, .T. ) ; #88 = DATE_TIME_ROLE ( 'creation_date' ) ; #92 = CARTESIAN_POINT ( 'NONE', ( 0.00, 0.00, 40.00 ) ) ; #93 = CIRCLE ( 'NONE', #63, 20.00 ) ; #94 = CARTESIAN_POINT ( 'NONE', ( -20.00, 0.00, 40.00 ) ) ; #97 = CIRCLE ( 'NONE', #122, 20.00 ) ; #96 = ORIENTED_EDGE ( 'NONE', *, *, #102, .F. ) ; #98 = DIRECTION ( 'NONE', ( -0.00, -0.00, -1.00 ) ) ; #101 = EDGE_LOOP ( 'NONE', ( #161, #64 ) ) ; #102 = EDGE_CURVE ( 'NONE', #125, #163, #97, .T. ) ; #103 = EDGE_LOOP ( 'NONE', ( #96, #126, #87, #137 ) ) ; #109 = DIRECTION ( 'NONE', ( 1.00, 0.00, -0.00 ) ) ; #111 = CARTESIAN_POINT ( 'NONE', ( 0.00, 0.00, 0.00 ) ) ; #113 = DIRECTION ( 'NONE', ( 1.00, 0.00, 0.00 ) ) ; #114 = EDGE_CURVE ( 'NONE', #163, #28, #138, .T. ) ; #115 = CARTESIAN_POINT ( 'NONE', ( 0.00, 0.00, 40.00 ) ) ; #116 = DIRECTION ( 'NONE', ( 1.00, 0.00, 0.00 ) ) ; #120 = DIRECTION ( 'NONE', ( 1.00, 0.00, 0.00 ) ) ; #121 = DIRECTION ( 'NONE', ( -0.00, -0.00, -1.00 ) ) ; #122 = AXIS2_PLACEMENT_3D ( 'NONE', #92, #44, #146 ) ; #125 = VERTEX_POINT ( 'NONE', #166 ) ; #126 = ORIENTED_EDGE ( 'NONE', *, *, #7, .T. ) ; #127 = CARTESIAN_POINT ( 'NONE', ( 0.00, 0.00, 40.00 ) ) ; #128 = FACE_OUTER_BOUND ( 'NONE', #55, .T. ) ; #130 = VECTOR ( 'NONE', #11, 1000.00 ) ; #131 = FACE_OUTER_BOUND ( 'NONE', #103, .T. ) ; #136 = MANIFOLD_SOLID_BREP ( 'Boss-Extrude1', #32 ) ; #137 = ORIENTED_EDGE ( 'NONE', *, *, #114, .F. ) ; #138 = LINE ( 'NONE', #94, #130 ) ; #141 = DIRECTION ( 'NONE', ( 0.00, 0.00, 1.00 ) ) ; #143 = ADVANCED_FACE ( 'NONE', ( #147 ), #82, .T. ) ; #144 = LINE ( 'NONE', #34, #52 ) ; #146 = DIRECTION ( 'NONE', ( 1.00, 0.00, 0.00 ) ) ; #147 = FACE_OUTER_BOUND ( 'NONE', #101, .T. ) ; #150 = CYLINDRICAL_SURFACE ( 'NONE', #85, 20.00 ) ; #154 = CARTESIAN_POINT ( 'NONE', ( 0.00, 0.00, 0.00 ) ) ; #155 = ADVANCED_FACE ( 'NONE', ( #36 ), #150, .T. ) ;

5-20

#156 = CARTESIAN_POINT ( 'NONE', ( -20.00, 0.00, 0.00 ) ) ; #157 = DIRECTION ( 'NONE', ( 0.00, 0.00, 1.00 ) ) ; #160 = ORIENTED_EDGE ( 'NONE', *, *, #114, .T. ) ; #161 = ORIENTED_EDGE ( 'NONE', *, *, #57, .T. ) ; #162 = LOCAL_TIME ( 11, 4, 56.00, #54 ) ; #163 = VERTEX_POINT ( 'NONE', #43 ) ; #165 = EDGE_LOOP ( 'NONE', ( #47, #26, #160, #175 ) ) ; #166 = CARTESIAN_POINT ( 'NONE', ( 20.00, 2.45E-015, 40.00 ) ) ; #168 = AXIS2_PLACEMENT_3D ( 'NONE', #14, #51, #116 ) ; #170 = ORIENTED_EDGE ( 'NONE', *, *, #53, .F. ) ; #171 = CIRCLE ( 'NONE', #168, 20.00 ) ; ENDSEC;

Figure 5.4 shows the B-Reps data structure retrieved from the cylindrical. The highest topology data will be line #136 which is called as Manifold Solid B-Reps and the next topology data is Closed Shell in Line #32. Both Manifold Solid and Closed Shell is topological data without geometry. The next topology is Advanced Face, which has four faces; two cylindrical faces and two plane.

Cylindrical Face:

#81: Radius 20, Reference Coordinate: (0, 0, 40)

Reference Vector (0, 0, -1) (-1, 0, 0)

#155: Radius 20, Reference Coordinate: (0, 0, 40)

Reference Vector (0, 0, -1) (-1, 0, 0)

Plane Face

#143: Reference Coordinate: (0, 0, 40), Ref Vector (0, 0, 1)

Ref Vector (1, 0, 0)

#79: Reference Coordinate: (0, 0, 0), Ref Vector (0 , 0, 1)

5-21

Ref Vector (1, 0, 0)

Figure 5.4: Example data structure for STEP data

The next topology after Advanced Face is Face Outer Bound and follows with

Edge Loop. Both of these topologies has no geometry. Then it follows with the

Oriented Edge that curve will be its geometrical properties.

In the following discussion, it will expand the B-Reps data structure of one of the cylindrical face which is mentioned in line 131. This cylindrical face comprises

Oriented Edges at line 96,126, 87, and 114. The oriented edges will have the following edges and as demonstrated in Figure 5.5.

Edge 96: Vertices (20, 0, 40) and (-20, 0, 40)

Circle with radius of 20 and reference vector of (0, 0, 1) and (1, 0, 0)

Edge 126: Vertices (20, 0, 40) and (20, 0, 0)

5-22

Line with vector of (0, 0, -1)

Edge 87: Vertices (20, 0, 0) and (-20, 0, 0)

Circle with radius of 20 and reference vector of (0, 0, 1) and (1, 0, 0)

Edge 137: Vertices (-20, 0, 40) and (-20, 0, 0)

Line with vector of (0, 0, -1)

Figure 5.5: Definition of cylindrical face 131

Based on the surface geometrical data, radius of the cylindrical face is stored into the face as this data is required to develop the mathematical equation for cylindrical face. However, at this stage this cylindrical face will have infinite length.

Radius can also be retrieved from circle edge, this is because radius is require in the mathematic of circle generation. The length of the surface can be retrieved from the vertices of the line edge on the cylindrical face.

Finally the B-Reps representation of the STE; P data is shown in Figure 5.6.

5-23

Figure 5.6 B-Reps data of STEP

5.5.2 ACIS

When the part is save as ACIS file, it will produce the following file:

-0 body $1 -1 -1 $-1 $2 $-1 $-1 F # -2 lump $3 -1 -1 $-1 $-1 $4 $0 F # -4 shell $-1 -1 -1 $-1 $-1 $-1 $5 $-1 $2 F # -5 face $6 -1 -1 $-1 $7 $8 $4 $-1 $9 forward single F T 0 2 0 3.1415926535897931 # -7 face $10 -1 -1 $-1 $11 $12 $4 $-1 $13 forward single F T 0 2 - 3.1415926535897931 0 # -8 loop $-1 -1 -1 $-1 $-1 $14 $5 F unknown # -9 cone-surface $-1 -1 -1 $-1 0 0 40 -0 -0 -1 -20 0 0 1 I I 0 1 20 forward I I I I # -11 face $15 -1 -1 $-1 $16 $17 $4 $-1 $18 forward single F F # -12 loop $-1 -1 -1 $-1 $-1 $19 $7 F unknown # -13 cone-surface $-1 -1 -1 $-1 0 0 40 -0 -0 -1 -20 0 0 1 I I 0 1 20 forward I I I I # -14 coedge $-1 -1 -1 $-1 $20 $21 $22 $23 reversed $8 $-1 # -16 face $24 -1 -1 $-1 $-1 $25 $4 $-1 $26 reversed single F F # -17 loop $-1 -1 -1 $-1 $-1 $27 $11 F unknown # -18 plane-surface $-1 -1 -1 $-1 0 0 40 0 0 1 1000 0 0 forward_v I I I I # -19 coedge $-1 -1 -1 $-1 $28 $29 $20 $30 reversed $12 $-1 #

5-24

-20 coedge $-1 -1 -1 $-1 $31 $14 $19 $30 forward $8 $-1 # -21 coedge $-1 -1 -1 $-1 $14 $31 $32 $33 reversed $8 $-1 # -22 coedge $-1 -1 -1 $-1 $27 $27 $14 $23 forward $17 $-1 # -23 edge $-1 -1 -1 $-1 $34 1.224646799147353e-016 $35 3.1415926535897931 $22 $36 forward @7 unknown F # -25 loop $-1 -1 -1 $-1 $-1 $37 $16 F unknown # -26 plane-surface $-1 -1 -1 $-1 0 0 0 0 0 1 1000 0 0 forward_v I I I I # -27 coedge $-1 -1 -1 $-1 $22 $22 $28 $38 forward $17 $-1 # -28 coedge $-1 -1 -1 $-1 $32 $19 $27 $38 reversed $12 $-1 # -29 coedge $-1 -1 -1 $-1 $19 $32 $37 $39 forward $12 $-1 # -30 edge $-1 -1 -1 $-1 $34 -0 $40 0.040000000000000001 $20 $41 forward @7 unknown F # -31 coedge $-1 -1 -1 $-1 $21 $20 $42 $43 forward $8 $-1 # -32 coedge $-1 -1 -1 $-1 $29 $28 $21 $33 forward $12 $-1 # -33 edge $-1 -1 -1 $-1 $35 -0 $44 0.040000000000000001 $32 $45 forward @7 unknown F # -34 vertex $-1 -1 -1 $-1 $30 $46 # -35 vertex $-1 -1 -1 $-1 $23 $47 # -36 ellipse-curve $-1 -1 -1 $-1 0 0 40 0 0 1 20 0 0 1 I I # -37 coedge $-1 -1 -1 $-1 $42 $42 $29 $39 reversed $25 $-1 # -38 edge $-1 -1 -1 $-1 $35 -3.1415926535897931 $34 1.224646799147353e-016 $27 $48 forward @7 unknown F # -39 edge $-1 -1 -1 $-1 $44 -3.1415926535897931 $40 1.224646799147353e-016 $29 $49 forward @7 unknown F # -40 vertex $-1 -1 -1 $-1 $30 $50 # -41 straight-curve $-1 -1 -1 $-1 20 2.4492935982947065e-015 40 -0 -0 - 1000 I I # -42 coedge $-1 -1 -1 $-1 $37 $37 $31 $43 reversed $25 $-1 # -43 edge $-1 -1 -1 $-1 $40 1.224646799147353e-016 $44 3.1415926535897931 $31 $51 forward @7 unknown F # -44 vertex $-1 -1 -1 $-1 $43 $52 # -45 straight-curve $-1 -1 -1 $-1 -20 0 40 -0 -0 -1000 I I # -46 point $-1 -1 -1 $-1 20 2.4492935982947065e-015 40 # -47 point $-1 -1 -1 $-1 -20 0 40 # -48 ellipse-curve $-1 -1 -1 $-1 0 0 40 0 0 1 20 0 0 1 I I # -49 ellipse-curve $-1 -1 -1 $-1 0 0 0 0 0 1 20 0 0 1 I I # -50 point $-1 -1 -1 $-1 20 2.4492935982947065e-015 0 # -51 ellipse-curve $-1 -1 -1 $-1 0 0 0 0 0 1 20 0 0 1 I I # -52 point $-1 -1 -1 $-1 -20 0 0 # End-of-ACIS-data

5-25

Figure 5.7 shows the sample of data structure of the above ACIS file. Line 0 will be the highest topology which in this case is Body. Then follows with Shell. When two or more parts are in one file such as in the assembly drawing, there will be one body and each part will be treated as one shell.

Then, it is followed with Face, the Face will have surface geometrical properties. In the case cylinder, there are for surfaces comprises two for each cone and plane surface.

Cone Surface

Line 9: Range <0, > with radius 20, Vertex (0, 0, 40), and vector (0, 0, 1)

Line 13: Range <-, 0> with radius 20, Vertex (0, 0, 40), and vector (0, 0, 1)

Plane Surface

Line 18: Start point (0, 0, 40), Vector (0, 0, 1) (1000, 0, 0)

Line 26: Start point (0, 0, 0), Vector (0, 0, 1) (1000, 0, 0)

5-26

Figure 5.7: Example BReps Data Structure

The next topology after Face is Loop. Then, it is followed with Coedge and

Edge. Coedge is introduced because Coedge will belong to specific face and at the same time, it will keep track of the direction loop by keeping track of the next and previous Coedge. On the other hand, one edge will be shared by two faces. As far as geometrical property is concerned, edge will have the geometry which is curve.

Finally, vertex will be lowest topological data and the coordinate of the vertex will be its geometrical data.

Line 9 cone surface will be described similar to STEP data. The definition of cone surface and ellipse curve in ACIS is based on the start and end angle, whilst

STEP will use the start and end point of the surface and curve.

The main reason for cylindrical surface is regarded as cone surface is that cone surface is the generic surface for cone and cylindrical. By setting various radius to

5-27 both edges of the cone, cylindrical and conical surfaces can be generated as illustrated in Figure 5.8.

Figure 5.8: Various definitions of cone surface

In all the topology and geometry reprsentation of B-Reps data is shown in

Figure 5.9.

5-28

Figure 5.9 B-Reps data structure

5.5 CASE STUDY ON NEUTRAL FILE

This section will discuss case study that is used to study the capability of the neutral file. In this section, the capability of STEP neutral file of AP 203 and AP 214 based on the part file and assembly file,

In fact for each model that includes the part and assembly model should have the following information.

5-29

• Shape data: Shape data includes the geometrical representation of the parts and the

form features that builds the part. Moreover, fonts, color, and annotation are also

regarded as part of the shape data.

• Non-shape data: The non-shape data incudes graphics data such as shaded images.

It also includes the measuring unit of the model and the precision of the units.

• Design data: The design data includes the information that designers generate

from geometric models for analysis purposes such as mass property, centroid, and

finite element mesh.

• Manufacturing data: The manufacturing data includes tooling, NC tool paths,

tolerancing, process planning, tool design, and bill of materials (BOM).

In the following, it will convert part and assembly file using STEP AP 203 and 214 file. Then the comparison will be made with the original file and the converted file with the intention to study the data that will be maintained and lost during file conversion process. In the case of the part file, the comparison will be made based on the feature manager and material, as well as shape, non-shape, and design data.

Then, the comparison will be carried out on assembly model and the comparison is made based on the feature manager and the constraint set to assemble the part. The third study is carried out to analyze the capability of the feature recognition feature of the CAD packages in interpreting the imported part.

5.5.1 Part File

Figure 5.10a shows the part file that has been used in this study. The part is constructed by three bosses. The bosses are resulted from extrusion processes. The feature manager is shown in Figure 5.10b. The part is made of copper and being

5-30 rendered using color and polished copper. The part is drawn using Solidwork 2014-

2015. The part is converted and opened again using the same software.

( a )

( b )

Figure 5.10 (a) Part 1 and its (b) feature manager

The units of the file is been set according MMGS (milimeter, gram, second) as shown in Figure 5.11.

Figure 5.11 Units setting

5-31

Table 5.1 compares the feature manager and units for Part 1 of the original part and the ones that have been converted using STEP AP 203 and AP 214. It is observed that the features and material is lost during the conversion process. For the converted part, the CAD packages regardse the feature as Imported and material information is lost during conversion process. STEP AP 214 is able to transfer the information on Appearance, but the data is not the same as the original part. In the case of units, the converted file will use the default value as MKS (meter, kilogram, second).

Table 5.1 Comparison of the feature manager and units

Original Part 1 Part 1 imported from AP 203 Part 1 imported from AP 214

Feature : 3 extruded bosses Feature: Imported Feature: Imported

Material: Copper Material: Material:

Appearance: Color and Polished Appearance: none Appearance: 3 type of colors copepr

File Setting: MMGS File Setting: MKS File Setting: MKS

Table 5.2 compares the properties of the part between the original part and the imported part. Since the material fails to be retrieved by the imported part, any properties related to material will show differences in values. This is supported by

Table 5.3 when the material of the original part has been removed and the properties of imported will be the same as the original part. This shows that there is no losses in the geometry of the part.

Table 5.2 Part Properties

Original Part 1 Part imported from AP 203 Part imported from AP 214

5-32

Density: 0.01gram/mm3 Density: 0 gram/mm3 Density: 0 gram/mm3

Mass: 2942.81 gram Mass: 330.65 gram Mass: 330.65 gram

Volume: 330652.63 mm3 Volume: 330652.63 mm3 Volume: 330652.63 mm3

Surface Area: 57019.91 mm2 Surface Area: 57019.91 mm2 Surface Area: 57019.91 mm2

Center of mass (mm): Center of mass (mm): Center of mass (mm): (0.00, 28.66, 2.61) (0.00, 28.66, 2.61) (0.00, 28.66, 2.61) Principal axes of inertia Principal axes of inertia Principal axes of inertia Ix = (0.00, 0.97, -0.26) Ix = (0.00, 0.97, -0.26) Ix = (0.00, 0.97, -0.26) Iy = (0.00, 0.26, 0.97) Iy = (0.00, 0.26, 0.97) Iy = (0.00, 0.26, 0.97) Iz = (1.00, 0.00, 0.00) Iz = (1.00, 0.00, 0.00) Iz = (1.00, 0.00, 0.00)

Principal moments of inertia: Principal moments of inertia: ( Principal moments of inertia: ( ( grams * square millimeters ) grams * square millimeters ) grams * square millimeters ) Taken at the center of mass. Taken at the center of mass. Taken at the center of mass. Px = 4970016.71 Px = 558428.84 Px = 558428.84 Py = 6637787.63 Py = 745818.83 Py = 745818.83 Pz = 6931377.76 Pz = 778806.49 Pz = 778806.49 Moments of inertia: ( grams * Moments of inertia: ( grams * Moments of inertia: ( grams * square millimeters ) square millimeters ) square millimeters ) Taken at the center of mass and Taken at the center of mass and Taken at the center of mass and aligned with the output aligned with the output aligned with the output coordinate system. coordinate system. coordinate system. Lxx = 6931377.76 Lxx = 778806.49 Lxx = 778806.49 Lxy = 0.00 Lxy = 0.00 Lxy = 0.00 Lxz = 0.00 Lxz = 0.00 Lxz = 0.00

Lyx = 0.00 Lyx = 0.00 Lyx = 0.00 Lyy = 5079234.07 Lyy = 570700.46 Lyy = 570700.46 Lyz = -412578.61 Lyz = -46357.15 Lyz = -46357.15

Lzx = 0.00 Lzx = 0.00 Lzx = 0.00 Lzy = -412578.61 Lzy = -46357.15 Lzy = -46357.15 Lzz = 6528570.26 Lzz = 733547.22 Lzz = 733547.22

Moments of inertia: ( grams * Moments of inertia: ( grams * Moments of inertia: ( grams * square millimeters ) square millimeters ) square millimeters ) Taken at the output coordinate Taken at the output coordinate Taken at the output coordinate system. system. system. Ixx = 9368333.19 Ixx = 1052621.71 Ixx = 1052621.71 Ixy = 0.00 Ixy = 0.00 Ixy = 0.00 Ixz = 0.00 Ixz = 0.00 Ixz = 0.00

Iyx = 0.00 Iyx = 0.00 Iyx = 0.00 Iyy = 5099324.22 Iyy = 572957.78 Iyy = 572957.78 Iyz = -192226.20 Iyz = -21598.45 Iyz = -21598.45

Izx = 0.00 Izx = 0.00 Izx = 0.00 Izy = -192226.20 Izy = -21598.45 Izy = -21598.45 Izz = 8945435.55 Izz = 1005105.12 Izz = 1005105.1

5-33

Table 5.3 Part 1 Properties (without material assigned to the original part)

Original Part 1 Part imported from AP 203 Part imported from AP 214

Density = 0.00 grams per cubic Density: 0 gram/mm3 Density: 0 gram/mm3 millimeter

Mass = 330.65 grams Mass: 330.65 gram Mass: 330.65 gram

Volume = 330652.63 mm3 Volume: 330652.63 mm3 Volume: 330652.63 mm3

Surface area = 57019.91 mm2 Surface Area: 57019.91 mm2 Surface Area: 57019.91 mm2

Center of mass (mm): Center of mass (mm): Center of mass: ( millimeters ) (0.00, 28.66, 2.61) (0.00, 28.66, 2.61) (0.00, 28.66, 2.61) Principal axes of inertia Principal axes of inertia Principal axes of inertia Ix = (0.00, 0.97, -0.26) Ix = (0.00, 0.97, -0.26) Ix = (0.00, 0.97, -0.26) Iy = (0.00, 0.26, 0.97) Iy = (0.00, 0.26, 0.97) Iy = (0.00, 0.26, 0.97) Iz = (1.00, 0.00, 0.00) Iz = (1.00, 0.00, 0.00) Iz = (1.00, 0.00, 0.00)

Principal moments of inertia: ( Principal moments of inertia: ( Principal moments of inertia: ( grams * square millimeters ) grams * square millimeters ) grams * square millimeters ) Taken at the center of mass. Taken at the center of mass. Taken at the center of mass. Px = 558428.84 Px = 558428.84 Px = 558428.84 Py = 745818.83 Py = 745818.83 Py = 745818.83 Pz = 778806.49 Pz = 778806.49 Pz = 778806.49

Moments of inertia: ( grams * Moments of inertia: ( grams * Moments of inertia: ( grams * square millimeters ) square millimeters ) square millimeters ) Taken at the center of mass and Taken at the center of mass and Taken at the center of mass and aligned with the output aligned with the output aligned with the output coordinate system. coordinate system. coordinate system. Lxx = 778806.49 Lxx = 778806.49 Lxx = 778806.49 Lxy = 0.00 Lxy = 0.00 Lxy = 0.00 Lxz = 0.00 Lxz = 0.00 Lxz = 0.00

Lyx = 0.00 Lyx = 0.00 Lyx = 0.00 Lyy = 570700.46 Lyy = 570700.46 Lyy = 570700.46 Lyz = -46357.15 Lyz = -46357.15 Lyz = -46357.15

Lzx = 0.00 Lzx = 0.00 Lzx = 0.00 Lzy = -46357.15 Lzy = -46357.15 Lzy = -46357.15 Lzz = 733547.22 Lzz = 733547.22 Lzz = 733547.22

Moments of inertia: ( grams * Moments of inertia: ( grams * Moments of inertia: ( grams * square millimeters ) square millimeters ) square millimeters ) Taken at the output coordinate Taken at the output coordinate Taken at the output coordinate system. system. system. Ixx = 1052621.71 Ixx = 1052621.71 Ixx = 1052621.71 Ixy = 0.00 Ixy = 0.00 Ixy = 0.00 Ixz = 0.00 Ixz = 0.00 Ixz = 0.00

Iyx = 0.00 Iyx = 0.00 Iyx = 0.00 Iyy = 572957.78 Iyy = 572957.78 Iyy = 572957.78

5-34

Iyz = -21598.45 Iyz = -21598.45 Iyz = -21598.45

Izx = 0.00 Izx = 0.00 Izx = 0.00 Izy = -21598.45 Izy = -21598.45 Izy = -21598.45 Izz = 1005105.12 Izz = 1005105.12 Izz = 1005105.1

The same comparison is carried out on two more polyhedral parts (Figure 12a and 12b) and one curved part (Figure 12c). As a result, there is no loss of the properties of the imported parts for polyhedral parts. However, the imported parts of the curved part show differences in the properties when they were compared with the original part. Table 5.4 shows the comparison of the properties between the Part

15.12c with the imported part using STEP AP 203 and AP 214.

( a ) ( b )

( c )

5-35

Figure 5.12 Tested parts

Table 5.4 Comparison for Part 5.12c

Original Part 5.12c Part 5.12c AP 203 Part 5.12c AP 214 Density = 0.00 gram/mm3 Density = 0.00 gram/mm3 Density = 0.00 gram/mm3

Mass = 311.87 gram Mass = 311.94 grams Mass = 311.94 grams

Volume = 311872.14 mm3 Volume = 311937.85 mm3 Volume = 311937.88 mm3 Surface area = 70328.74 mm2 Surface area = 70328.90 mm2 Surface area = 70328.60 mm2 Center of mass: ( mm ) Center of mass: (mm) Center of mass: (mm ) (-27.90, 5.00, 19.86) (-27.91, 5.00, 19.85) (-27.91, 5.00, 19.85) Principal axes of inertia Principal axes of inertia Principal axes of inertia Ix = (1.00, 0.00, 0.07) Ix = (1.00, 0.00, 0.07) Ix = (1.00, 0.00, 0.07) Iy = (0.07, 0.00, -1.00) Iy = (0.07, 0.00, -1.00) Iy = (0.07, 0.00, -1.00) Iz = (0.00, 1.00, 0.00) Iz = (0.00, 1.00, 0.00) Iz = (0.00, 1.00, 0.00)

Principal moments of inertia: ( Principal moments of inertia: ( Principal moments of inertia: ( grams * square millimeters ) grams * square millimeters ) grams * square millimeters ) Taken at the center of mass. Taken at the center of mass. Taken at the center of mass. Px = 348587.45 Px = 348608.15 Px = 348608.00 Py = 2105706.82 Py = 2106500.78 Py = 2106526.41 Pz = 2449096.25 Pz = 2449910.27 Pz = 2449935.76

Moments of inertia: ( grams * Moments of inertia: ( grams * Moments of inertia: ( grams * square millimeters ) square millimeters ) square millimeters ) Taken at the center of mass and Taken at the center of mass and Taken at the center of mass and aligned with the output aligned with the output aligned with the output coordinate system. coordinate system. coordinate system. Lxx = 357522.75 Lxx = 357595.44 Lxx = 357593.96 Lxy = -0.40 Lxy = -0.14 Lxy = 0.83 Lxz = 124982.22 Lxz = 125371.16 Lxz = 125362.86

Lyx = -0.40 Lyx = -0.14 Lyx = 0.83 Lyy = 2449096.25 Lyy = 2449910.27 Lyy = 2449935.76 Lyz = 0.18 Lyz = -0.06 Lyz = -0.15

Lzx = 124982.22 Lzx = 125371.16 Lzx = 125362.86 Lzy = 0.18 Lzy = -0.06 Lzy = -0.15 Lzz = 2096771.52 Lzz = 2097513.49 Lzz = 2097540.45

Moments of inertia: ( grams * Moments of inertia: ( grams * Moments of inertia: ( grams * square millimeters ) square millimeters ) square millimeters ) Taken at the output coordinate Taken at the output coordinate Taken at the output coordinate system. system. system. Ixx = 488379.70 Ixx = 488262.76 Ixx = 488262.70 Ixy = -43510.18 Ixy = -43529.99 Ixy = -43528.32 Ixz = -47875.28 Ixz = -47412.61 Ixz = -47419.29

Iyx = -43510.18 Iyx = -43529.99 Iyx = -43528.32 Iyy = 2814962.15 Iyy = 2815755.54 Iyy = 2815775.08 Iyz = 30975.53 Iyz = 30954.59 Iyz = 30954.66

Izx = -47875.28 Izx = -47412.61 Izx = -47419.29 Izy = 30975.53 Izy = 30954.59 Izy = 30954.66

5-36

Izz = 2347374.00 Izz = 2348288.41 Izz = 2348307.97

5.5.2 Assembly File

The case study proceeds with the conversion of assembly file into STEP AP 203 and

AP 214. Figure 5.13 shows the assembly model. The assembly has four parts; namely part 1, part 2, part 3, and part 4. The parts have been constraint that will only allow the part 3 to slide on the part 2 as part 1 is rotated. This assembly file is saved as

STEP AP203 and AP214 and both STEP files will be opened again.

Figure 5.13: Assmbly model

Similar result from part file, STEP AP 203 is able to import the shape only without any colour and STEP AP 214 is able to import the shape with colour.

However, both files fail to import the constraint during assembly and this causes the original intention to show the movement fail. When both files are saved, both STEP

AP files will save them as the original name.

5-37

Figure 5.14: Absence of constraint set during assembly for ( a ) STEP AP 203 and ( b

) STEP AP 214

5.5.3 CAD package conversion facility

Most of the CAD packages provide facility to generate the features that will form the models. This conversion facility rely on the capability of feature recognition technique that is embeded inside the conversion facility.

In the following, it will study the capability of the feature conversion facility by one of the CAD packages which is Solidwork 2014-15. Figure 5.15 shows the part and the constraints have been set to the original part.

Figure 5.15 Tested Part 1 and its sketch profile

5-38

Figure 5.16 shows the sketch profile has lost it dimensional constraint and causes the profile is not fully constraint. Therefore, feature recognition facility is able to develop the profile without any dimensional constraint.

Figure 5.16 Sketch profile resulted from the feature recognition facility

Then, the part in Figure 5.10 is tested using the feature recognition facility. The part is created using three extruded boss as shown in Figure 5.17a and their profiles are shown in Figure 5.17b – 5.17d.

5-39

Figure 5.17 (a) feature tree of Part 5.10 and (b – d ) its profile

When the feature conversion facility on the imported part, two revolved and one boss extruded features are generated (Figure 5.18a) which are not similar to the original part. The profiles of these features are shown in Figure 5.18b to 5.18d.

5-40

Figure 5.18: ( a ) feature tree and ( b – d ) its profiles after application of feature

recognition facility.

5-41

CHAPTER 6

ENGINEERING APPLICATIONS

This chapter discusses the engineering applications of CAD software. There are four applications that are discussed in this chapter. The first application is the use of CAD package as the tool in the design. The second application is the application sketch of the feature and parametric modelling for solving some of the engineering problem.

Then, it is followed with the discussion the application of Application Programming

Interface (API) in the development of engineering related software. Finally, the application of the CAD packages in the development of the intelligent system which is regarded as Design Wonder will be discussed.

6.1 APPLICATION 1: TOOL IN DESIGN

The application of CAD packages to produce model, and engineering drawing for the visualization purposes has been discussed in previous chapter. This chapter will further discuss the engineering applications of the parametric and feature based modelling. The application focuses on the design review and evaluation as well as to make CAD package as s full-fledged design platform.

Nowadays, CAD packages can become full-fledged design platform. It starts from the modelling of parts, then it follows with the assembly of the parts to become a complete design. With the part files and assembly file, the part and the assembled model can go through a number of design checking and evaluation tools that are available in the CAD software. Such tools are manufacturing verification, collision checking, and even FEA. When the part and assembly are fully complied with the

6-1

design requirements, documentation of the design such as detail and assembly drawing can be produced. Figure 6.1 shows the design of small differential gear which modelling, clearance checking, FEA and documentation are integration in one

CAD platform.

Figure 6.1: Examples of design checking and evaluation

When CAD packages provides tools for design within a single platfrom, the design process becomes more efficient. The integrity of the design can be checked using FEA and if alteration of dimensions is required, the parametric modelling allows the alteration to be make directly to the part.

With the advancement of the IT related technology, it is possible to make the different process in design to be carried out in diferent places in the world. When the modelling process is possible to be carried out on one part of the world, whilst on the other part of the world is sleeping. When the modelling is completed, the design can be shared electronically by other people from other part of the world and intergrity of the design can be evaluated. The amendment on the part will be continued by the people whose the part is originally modelled, whilst the people who are doing the verification are sleeping. Therefore, with the advancement of internet, cloud storage,

6-2

and other IT related technology, the design process using CAD packages becomes boundariless and can be done continuously.

6.2 APPLICATION 2: SKETCH BASED APPLICATIONS

This section discusses the applications of sketch is design related activities. Sketch can be used for vector analysis. Sketch can also be used to estimate the length of the mechanism as well as to estimate whether the locust of the mechanism.

Both of these applications are founded with the basis that when the profile is fully constraint, any additional dimensions that are set to the profile will be regarded as driven dimension and this driven dimension cannot be changed by users as it relies on other dimension. Figure 6.2a shows a profile that is been fully constraint and additional dimension as shown in Figure 6.2b is regarded as driven dimension.

( a )

6-3

( b )

Figure 6.2: (a) Fully constraint profile with (b) driven dimension

In the engineering application, the driven dimension will become the parameter to be identified. In the following, it will discuss the application of fully constraint profile with driven dimension in solving the vector analysis and animation of mechanism.

6.2.1 Vector Analysis

Vector analysis is used to calculate the force and relative velocity or acceleration.

Equation 6.1 and 6.2 are used to calculate the force and relative velocity or acceleration.

 in  FT   Fi … (6.1) i0

VB  VA VA/ B … (6.2)

6-4

Figure 6.3a and 6.3b illustrates the problems for equation 6.1 and 6.2 respectively. In the following, it will shows two examples of using the sketch profile in solving both problems.

Figure 6.3: Problems for equation 6.1 and 6.2.

Example 6.1

Figure 6.4: Problem for Example 6.1

Figure 6.4 shows three forces of F1 = 300 N, F2 = 450 N and F3 = 600 N that pulls the hook. At the same, the hook will react with the same magnitude, but in the opposite direction of total force exerted to the hook. Using sketch, determine the magnitude and direction of the reaction force exerted by the hook.

In this case, equation 6.1 will be

6-5

 FT  F1 F 2  F3

Or, it can be translated as

4 F    F1  900  F2  450  F3  tan 1( ) T 3

Therefore, all the forces and their angle with one fix point will create fully constraint profile as shown in Figure 6.5a. Therefore, the line length and their angle are regarded as driver dimensions. The drivers dimensions means that the dimension can be changed. Since angle of F3 requires tan-1 (4.0/3.0), equation is used to calculate the angle.

When another line is added to make the profile to be closed as shown Figure

6.5b, the profile is still fully constraint profile. Therefore, additional dimensions will be regarded as driven dimension. Therefore, the driven dimensions can be changed and they relies on the driver dimensions.

Figure 6.5: Solution using sketch

6-6

The resultant force is 1098.99 N.

6.2.2 Mechanism

The fully constraint profile is applicable in mechanism design. Four bar linkages and slider crank mechanism are used to demonstrate the application of sketch.

In the case of four bar linkages, there will be ground, and three other linkage to form the mechanism. One example is shown in Figure 6.6. There are dimensions needed, ground as L0, and there other three linkages, L1 to L3. The movement of mechanism can be produced when L1 is rotated by changing the angle 1.

Figure 6.6: Example four bar linkages

Based on the length of the linkages and the rotation of L1, the sketch representation of the mechanism can be generated as shown in 6.7. Fully constraint can be achieved by setting the dimensions to all the linkages and angle of rotation for

L1 and fixing the ground link. Fixing the ground is done by fixing on the ground link end with horizontal geometrical constraint.

6-7

Figure 6.7: A fully constraint profile for four bar linkage

By changing the rotation angle of L1, the movement of the mechanism can be visualized. Changing the angle can be carried out using dialogue box for angle dimension as shown in Figure 6.8. Slider on the dialogue box can be used to change the angle continuously.

Figure 6.8: Dialogue box for angle dimension

Since the movement of the mechanism can be fully visualized by sliding the arrow, the movement constraint can be detected if there is any. In the case of the above mechanism, it cannot be formed when the angle is from -190 (3410) to 190 as shown in Figure 6.9.

6-8

Figure 6.9: Limits for the mechanism

Similar approach can be carried out to study the slider crank mechanism. The length of both linkages and the direction of slider must be set first. When the first linkage rotates, the slider will move and stroke can be achieved. Therefore, to have fully constraint profile of slider crank mechanism, length of both linkages and angle of rotation together with the point that is fixed to ground will make the slider crank profile to be fully constraint. When the profile is fully constraint, additional dimension to measure the stroke becomes driven dimensions. Fully constraint profile with one driven dimension is shown in Figure 6.10. Figure 6.10 also shows that by changing the rotation angle of the linkage, different stroke length can be determined.

Figure 6.10: Slider crank mechanism

Example 6.2

6-9

Figure 6.11 shows three types of mechanism. Draw the profile to represent each mechanism and set the constraint to make the profile fully constraint. Hence, the movement of the mechanism can be shown.

Figure 6.11: ( a ) prrp and (b) rprr mechanism

Solution

The representation of the revolute joint is a pin joint and the representation of the prismatic is slider. a) prrp mechanism (Figure 6.12a)

This mechanism comprises two links. The ground link (L0) is set by two lines that are horizontal and vertical and the mechanism link (L1) is set by a straight line. The prismatic joint is set by constraining the end of L1 according to its allowable path which is horizontal on one end and vertical for the other end. The length of the mechanism will also constraint the mechanism to make it behave as it intended. The motion of the mechanism can be seen by the changing the angle between the mechanism and the ground.

6-10

b) rprr mechanism (Figure 6.12b)

There are three linkages for this mechanism. The ground link (L0) and the second link

(L2) are set by a line with specified length. The prismatic joint between link L1 and

L2 is set by constraining the end point that touches L1 coincides with the line that represents the first link L1. Finally, the movement of the mechanism can be seen by setting the angle between the first link L1 and ground link L0.

( a ) ( b )

Figure 6.12: The representation of the mechanism

6.2.3 Sketch Block

When a group of entities is treated as one entity, the entities must be grouped as sketch block. This sketch block can be used to show the animation of a mechanism.

Examples of sketch block are shown in Figure 6.13.There are three sketch blocks;

Two of the sketch blocks comprises of line and circle and the other sketch block is just a circle.

6-11

Figure 6.13: Example of sketch block

The intention the sketch block to allow the circle of Sketch Block 3 to be tangential to the lines Sketch Block 1 and 2. As a result, the movement of Sketch

Block 1 will cause an opening of Sketch Block 1 and 2 as demonstrated in Figure

6.14.

Figure 6.14: The intention to group the sketch blocks.

This is possible by setting the appropriate geometrical constraints to the entities of the sketch blocks. The geometrical constraint that should be set are as follows:

Center point of circle in Sketch Block 1: fix

Line of Sketch block 1: horizontal

6-12

Center points of both circles of Sketch Block 1 and 2: Coincide

Circle and both lines of Sketch 1 and 2: tangent

These geometrical constraints are shown in Figure 6.15.

Figure 6.15: Geometrical constraints of the sketch blocks

By further manipulating the drive and driven dimension, various problems can be solved. Example of problem are as follows:

Problem 1: What is the position Sketch Block 3 if the end opening is set as certain vertical length?

Based on the problem, the dimension of the opening will be the drive dimensions, whilst the distance between the circle center point of Sketch Block 3 and center point of the circle of either Sketch 1 or 2 will be set as driven dimension.

Therefore, by setting the vertical dimension of the opening, it will force the Sketch

Block to move to ensure the opening dimension is achieved. The position of the

Sketch Block 3 is shown by the driven dimension. This is shown in Figure 6.16.

6-13

Figure 6.16: Drive and driven dimensions for Problem 1.

Problem 2: What is the the vertical opening if the diameter of the Sketch Block 3 and distance between the center point of Sketch Block 1 and 3 are set to constant value.

Based on the problem, the driving dimensions are the diameter of Sketch

Block 3 and the distance between the center point of Sketch Block 1 and 3. Whilst, the dimension of vertical distance of the opening is to driven.

Figure 6.17 shows the distance between the center point of Sketch Block 1 and 3 is set to 2.8 in with various diameter of the Sketch Block 3. When both dimensions are set, they will affect the vertical distance of the opening.

6-14

Figure 6.17: Problem 2

6.2.3 Power Transmission Engineering Problem

In engineering, circle can represent pitch circle of a pulley or a gear in power transmission problem. Power can be transmitted through belt and the mating tooth of pair of gears. Both belt and gear can be modelled using sketch and therefore, sketch can be used to set the initial design parameter for power transmission engineering problem.

Belt

Two or more circles that represent pulley can be connected using belt command. Belt command also allows the user to set the connection as open or cross. This is possib;e by changing the direction of attachment (represents as arrow), belt configure can be changed from Figure 6.18(a) and 6.18(b) and vice versa. Similar action can be done on more than two pulleys as demonstrated in Figure 6.19.

Figure 6.18: (a) Open and (b) cross belt configuration

6-15

Figure 6.19: More examples of belt connections

In engineering problem, the length of the belt can be varied or selected fixed length. The length of the flat and round belt can be varied and therefore, the parameter to be sought directly from the belt properties. In the case of belt, such as V and timing belt, with fixed length, the sought parameter is center to center distance between two pulleys. This can be done by setting one of the pulley to be fixed and let the belt length be the driving. Figure 6.20 shows two different lengths of belt and the center to center distance will be the parameter to be sought.

750 mm 850 mm

Figure 6.20: Distance center to center with (a) 750 mm and (b) 850 mm belt

Traction

The other possible connection is traction type which can represent gear connection.

The diameter of the circle represents the pitch circle of the gear. By selecting both

6-16

circle of the sketch block and choose traction to constraint both sketch blocks, connection between two circle using traction is created. This is demonstrated in

Figure 6.21. There are three sets of gear. Gear 1 and 2 is a single gear, whilst Gear 3 has two gears with different diameter. By setting the traction between Gear1 with small gear of Gear 3 and big gear of Gear 3 with Gear 2, gear train as shown in Figure

6.21b is produced.

Figure 6.21: Traction connection between gears

6.2.4 Engineering Applications of Sketch Blocks

In the following, it will demonstrate the applications of sketch block in engineering problem. The discussion focusses on the constraints to be set.

Example 6.2: Mechanism for the cam movement

In this example, it will demonstrate the application of sketch block in determining the displacement of the follower. Initially, there are five sketch blocks, named as SB1 – 5 as shown in Figure 6.22a. The final assembly of the mechanism is shown in Figure

6.22b; when gear in SB1 rotates, it will drive gear in SB2. As the gear in SB2 rotates, it will drive the pulley in SB2 to drive pulley in SB3 through belt. As a result of gear in SB1 rotates, cam will rotate. As the cam rotates, it will push and pull the follower according to its profile. The vertical movement of the follower will be guided by

6-17

follower guide. Finally, the vertical displacement of the follower will be the main driven dimension.

( a )

( b )

Figure 6.22: (a) Initial sketch blocks and (b) final mechansim

6-18

Solution

Based on the working principle, SB1 will drive SB2 using traction connection, SB2 will drive SB3 using belt, SB3 will use its cam profile to push and pull SB4 and SB5 will guide the movement of SB4.

Therefore;

Constraint between SB1 and SB2 (Figure 6.23a)

Fix: center point of SB1

Horizontal: center of SB1 and SB2

Traction: gear of SB1 and driven gear of SB2.

Constraint between SB 2 and SB3 (Figure 6.23b)

Horizontal: center of SB2 and center of pulley at SB3

Belt: pulley of SB2 and pulley of SB3

Constraint between SB3 and SB4 (Figure 6.23c)

Vertical: both center points of SB4

Tangent: circle at the bottom of SB4 and outer profile of SB3

Constraint between SB4 and SB5 (Figure 6.23d)

Fix: bottom left and top right of the follower guide

Horizontal dimension: side of follower and side of the follower guide. The

dimension is used to ensure the movement of the follower.

6-19

Vertical dimension: center of circle on the top of the follower and top edge of the follower guide. This dimension should be set as driven to allow the displacement can be measured.

( a ) ( b )

( c ) ( d )

Figure 6.23: Steps to create the mechanism

6-20

When all the constraints are set to all the sketch blocks, displacement of the follower can be retrived from the animation when gear 1 rotates. This is illustrated in

Figure 6.24a and 6.24b.

( a ) ( b)

Figure 6.24: The movement of the mechanism

Example 6.3: Ergonomic Study of a chair

Using the sketch block, your main task is to set the minimum and maximum height of a chair which the height of the chair is adjustable. The design specification states that the height of a person for Malaysian market to use ranges from 1.4 m to 1.8 m. Based on this information, discuss the implementation of the sketch block to estimate the suitable minimum and maximum height of the chair.

Solution

In this example, the aim is to set the range of height for chair for Malaysian market.

Since the length of human part can be in form of ratio to the height, the human skeleton can be model using equations. The equations that estimate the length of the body parts are

6-21

Foot length L1 = 0.152h Foot height L2 = 0.043h

Lower leg length L3 = 0.242h Upper leg length L4 = 0.245h

Upper body length L5 = 0.339h Head L6 = 0.181h

Where h: height of the person

Since the human can be modelled using equations, equations can be used. By using height as the global variables, the length of all the body parts can be calculated.

Figure 6.25 shows the calculation of the body parts using equations features.

Figure 6.25: Eqautions for body parts

The body part can be drawn as ellipse which both ends of the major axis will be connected to other body part. Assuming the angle between the lower and upper leg is 85o during sitting, the sitting position of the human can be modelled.

Since the aim is to estimate the height of the chair, the vertical distance between the floor and lower leg is set as driven dimension. By setting the height in the equation to 1400 m and 1800 m, sitting position of 1.4 m and 1.8 m human can modelled as illustrated in Figure 6.26a and 6.26b respectively. The height of the chair should vary from 338 mm to 436 mm to cater the person with the height of 1.4 m to

1.8m.

6-22

( a ) ( b )

Figure 6.26: Sitting position of a human with (a) 1.4 m and (b) 1.8 m

6.2.5 Command in Solidwork

The following are the commands that related to the sketch block.

Make Block

Make Block is a command to create a block after all the entities are selected. The pull down menu is Tools  Block  Make Block and shown in Figure 6.27a. The command can be also be activated after the entity selection is done by pressing the right button of the mouse. When pressing the right button of the mouse, pop-up menu as shown in Figure 6.27b appears and when icon make block is selected, sketch block is created.

6-23

( a ) ( b )

Figure 6.27: Make block command using (a) pull down and (b) pop-up menu

Make Path

Make path is a command to convert a number of entities as one path. This is applicable such as to form the profile of SB3 in Figure 6.23a. The command can be activated by using pull down menu (Tools  Sketch Tools  Make Path) or pressing right button of the mouse. Both methods are illustrated in Figure 6.28a and 6.28b respectively.

6-24

( a ) ( b )

Figure 6.28: Make path using (a) pull down and (b) pop-up menu

Belt/Chain

Belt/Chain command is a command that is used to create belt or chain connection between two selected circles of two different sketch blocks. This command can be activated by using pull down menu (Tools  Sketch Entities  Belt/Chain) as shown in Figure 6.29.

6-25

Figure 6.29: Belt/Chain command using pull down menu

Traction

Traction is a constraint that is set between two circles of two different sketch blocks.

When both sketch blocks of circles are selected, side menu as shown in Figure 6.30 appears and by selecting traction constraint, both circles will have traction connectivity.

6-26

Figure 6.30: Side menu to set the traction connectivity

6.3 APPLICATION 3: PROGRAMME INTERFACE (API)

The most common method to build part or model is using the user interface. Users will model the part according the steps. If similar part is drawn by other user, similar steps should be followed. This shows there is a possible of waste of human resource when this kind of repetition happens. This setback can be overcome by using application interface program (API). By imitating the command to model by method of programming, the program can be executed repeatedly and the model can be created. Moreover, the program can be created in such a way that user can define the important parameters of the part.

In this section, it will not go through the detail of programming. However, it will start with a guide to create a VBA simple program using macro. With this macro,

6-27

the program can be extended to add user interface or mathematical equations. Finally, it will discuss the capability of API programming by using two case studies.

6.3.1 Macro Method

Macro can be activated under the Tools pull down menu. There are five commands under macro the command are

Run: to execute the macro

Stop: to stop recording of the macro

Record: to start the recording of the macro

New: to start a macro

Edit: to edit the macro

Figure 6.31 shows the icon of the commands

Figure 6.31: Icon for macro command

In the following discussion, program to build part in Figure 6.32 is demonstrated.

Firstly, macro will record the step to build the part and as a result, VBA program is generated from this recording process. Using the program generated by the macro, explanation is done on the program and then follows with the modification of the program until the user is able to input the parameters using user interface. If the input is wrong, error prompting will be displayed.

6-28

Figure 6.32: Illustrative example

Start a new macro

The recording of the macro starts by activating the macro record command. When the record command is activated, user can start draw the part, commencing from drawing profile (Figure 6.33a) and extruding the profile (Figure 6.33b). Once the part is modelled, the recording can be stopped by pressing macro stop command. Then, the macro needs to be saved and named as mymacro.swp. Then, by pressing the macro edit command and select mymacro.swp file, programming windows appear and display the programming of the file.

( a ) ( b )

Figure 6.33: Steps to build the model

The recorded program is as the following

'******************************************************************** ‘C:\Temp\swx8292\Macro1.swb - macro recorded on 05/28/14 by user

6-29

'******************************************************************** Dim swApp As Object

Dim Part As Object Dim boolstatus As Boolean Dim longstatus As Long, longwarnings As Long

Sub main()

Set swApp = _ Application.SldWorks

Set Part = swApp.ActiveDoc Part.ClearSelection2 True Dim skSegment As Object Set skSegment = Part.SketchManager.CreateLine(-0.061212, 0.062674, 0#, 0.070844, 0.020752, 0#) Set skSegment = Part.SketchManager.CreateLine(0.070844, 0.020752, 0#, - 0.023901, -0.101242, 0#) Set skSegment = Part.SketchManager.CreateLine(-0.023901, -0.101242, 0#, - 0.161406, -0.071478, 0#) Set skSegment = Part.SketchManager.CreateLine(-0.161406, -0.071478, 0#, - 0.061212, 0.062674, 0#) Set skSegment = Part.SketchManager.CreateCircle(-0.0457, -0.017817, 0#, - 0.022224, -0.03752, 0#)

Part.ShowNamedView2 "*Trimetric", 8 Part.ClearSelection2 True

Dim myFeature As Object Set myFeature = Part.FeatureManager.FeatureExtrusion2(True, False, False, 0, 0, 0.06223, 0.00254, False, False, False, False, 1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, True, True, True, 0, 0, False) Part.SelectionManager.EnableContourSelection = False End Sub

Program Explanation

The first part of the program before Sub Main is the notation of the macro and variable global declaration. Any line that starts with symbol ‘ is the line that will not be executed by the program and it can be used to write note on the program. In the mymacro.swp program, the first three lines are a notation that has information of the macro.

6-30

On the fourth line after the notation, variables are declared. Since the above variables are declared before the main program, they will be global declaration which means that the variables can be used by all the functions in the program.

The following shows the first part of mymacro.swp:

'******************************************************************** ‘C:\Temp\swx8292\Macro1.swb - macro recorded on 05/28/14 by user '******************************************************************** Dim swApp As Object

Dim Part As Object Dim boolstatus As Boolean Dim longstatus As Long, longwarnings As Long

Variable declaration is structured as follows:

Dim variable_name As variable_type

variable_name is the name of the variable assigned by the programmer, whilst the variable_type indicates the types of variables. A number of variable names can be assigned to a single variable type for each declaration.

The type of variables are as follows

i. Float or double:

Dim A, B, C As Double,

ii. Integer or long:

Dim D As Integer

iii. Array declaration:

Dim Point(1 To 50) As Integer Dim Point As Variant

iv. Structure data declaration:

Type Point

6-31

x As Double y As Double z As Double End Type Dim Pt(1 to 10) As Point

In addition to the variable declaration, the Solidwork entites have its own declaration. This declaration is applied to all solidwork entities such as feature, part, or line. Example of the entity declaration is in the following.

Dim Feature As Object Dim skSegment As Object

After the global variable declaration, the main program will follow. The main program starts with Sub main() statement and ends with End Sub statement. The main task of the program will be within the main program body. In case of Solidwork macro, activation of the solidwork will be the first line of the main program.

Sub main()

Set swApp = _ Application.SldWorks

Set Part = swApp.ActiveDoc … ‘This is the body of the program

End Sub In the main body, there are basically two main tasks. The first task is to draw four lines and circles and the second task is to extrude the profile with a given height.

The following will be the programming for the former task.

Dim skSegment As Object Set skSegment = Part.SketchManager.CreateLine(-0.061212, 0.062674, 0#, 0.070844, 0.020752, 0#) Set skSegment = Part.SketchManager.CreateLine(0.070844, 0.020752, 0#, - 0.023901, -0.101242, 0#) Set skSegment = Part.SketchManager.CreateLine(-0.023901, -0.101242, 0#, - 0.161406, -0.071478, 0#) Set skSegment = Part.SketchManager.CreateLine(-0.161406, -0.071478, 0#, - 0.061212, 0.062674, 0#)

6-32

Set skSegment = Part.SketchManager.CreateCircle(-0.0457, -0.017817, 0#, - 0.022224, -0.03752, 0#) Firstly, lines and circle are solidwork entities and they named as skSegment and Object will be the variable type. Then, four lines are drawn using CreateLine function that belongs to SketchManager group and circle is drawn using CreateCircle function that is also belonged to same SketchManager group.

To fully understand the meaning of the both function, API Help Topics can be used and search for the commands. In case of lines, the parameters are (x1, y1, z1, x2, y2, z2) and for circles, the parameters are (xc, yc , zc of the center point, xp, yp, zp of another point on circle). The coordinates are in meters.

In the case of second task, it will be as the following:

Dim myFeature As Object Set myFeature = Part.FeatureManager.FeatureExtrusion2(True, False, False, 0, 0, 0.06223, 0.00254, False, False, False, False, 1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, True, True, True, 0, 0, False) Extruded is named as myFeature with Object type. FeatureExtrusion2 command that is belonged to FeatureManager group will extrude the profile and create the extruded part. For extrusion of a profile, there is a number variables needs to set. The explanation of the variables is as follows.

Solidwork command for extrusion is

pFeat = FeatureManager.FeatureExtrusion2 ( sd, flip, dir, t1, t2, d1, d2, dchk1, dchk2, ddir1, ddir2, dang1, dang2, offsetReverse1, offsetReverse2, translateSurface1, translateSurface2, merge, useFeatScope, useAutoSelect, t0, startOffset, flipStartOffset )

Some of the variables are as follows.

sd: TRUE: single ended FALSE: double ended

flip TRUE to flip the direction to cut (not applicable for base mode)

6-33

dir TRUE to flip the direction to extrude

t1 and t2 Blind 0

MidPlane 6

OffsetFromSurface 5

ThroughAll 1

ThroughNext 2

UpToBody 7

UpToSurface 4

UpToVertex 3

To make the understanding of the variables easier, these variables are similar to the command used to extrude the profile. Figure 6.34 shows the variables that are input on the side menu during extrusion process.

6-34

Figure 6.34: Variables of the extrsuion API function on the side menu

6.3.2 MyFirst API program

When the macro is recorded, the program can be modified. In the next section, programming modification is carried out. The aim of the modification is to allow the user to key in the bottom left corner of the profile together with the height and width of the outer profile. The circle is assumed at the center of the profile. Then, the user is allowed to key in the radius of the circle. Finally, the program will verify whether the circle drawn will exceed the outer profile. If it exceeds, the program will ask the user to key different radius and advice the user the maximum radius should be key in.

Therefore, the modification of the program will be carried stages. The stages are as follows

i. Setting the variable assignment to the line and circle function

ii. Creating the user input

iii. Prompting the error

In the following, it will discuss the stage in detail.

Programming modification: assignment of the variables to line and circle

The first task is to modify the program that draw the outer profile based

i) Coordinates of the bottom left corner of the outer profile,

ii) length and height of the outer profile,

iii) the radius of the inner circle,

6-35

iv) height of the extrusion

The inner circle is assumed to be located in the center of the outer profile.

Based on this input, other coordinates can be calculated (refer to Figure 6.35)

Figure 6.35: Calculation of the vertices of the profile

The user input will be P1 (x1, y1), length (L), height (H), and circle radius (R) and based on this input, other variables will be as the following

Coordinates of the outer profile: P2 (x1 + L, y1),

P3 (x1+L, y1+H), and

P4 (x1, y1+H)

Center of the circle: C1 (x1 + 0.5L, y1 + 0.5H)

Step 1: Variable declaration

In this program, the variables are coordinates, length, height, and radius. The length, height, and radius can be declared as double and coordinates can be declared as structured variable called as point.

The additional lines for the program are:

6-36

Type Point ‘this is declared as global variable x As Double y As Double End Type

Dim L, H, R As Double

L = 10# H = 20# R = 5#

Dim P(1 To 4) As Point P(1).x = 0 P(1).y = 0

P(2).x = P(1).x + L P(2).y = P(1).y

P(3).x = P(1).x + L P(3).y = P(1).y + H

P(4).x = P(1).x P(4).y = P(1).y + H

Dim C1 As Point

C1.x = P(1).x + 0.5 * L C1.y = P(1).y + 0.5 * H

Dim C2 As Point

C2.x = C1.x + R C2.y = C1.y

Dim extHeight As Double extHeight = 2

Step 2: Inserting the related variables to the API functions

6-37

Firstly, the lines drawn should be named as L1 to L4. Then, the respective variables will be replaced with the respective variables. The advantage of giving names to the entities is the names can be used as the method during entity selection.

The insertion of the variables is indicated by the bold text.

Dim L1, L2, L3, L4, skCircle As Object

Set L1 = Part.SketchManager.CreateLine(P(1).x, P(1).y, 0#, P(2).x, P(2).y, 0#) Set L2 = Part.SketchManager.CreateLine(P(2).x, P(2).y, 0#, P(3).x, P(3).y, 0#) Set L3 = Part.SketchManager.CreateLine(P(3).x, P(3).y, 0#, P(4).x, P(4).y, 0#) Set L4 = Part.SketchManager.CreateLine(P(4).x, P(4).y, 0#, P(1).x, P(1).y, 0#) Set skCircle = Part.SketchManager.CreateCircle(C1.x, C1.y, 0#, C2.x, C2.y, 0#)

… Set myFeature = Part.FeatureManager.FeatureExtrusion2(True, False, False, 0, 0, extHeight, 0, False, False, False, False, 1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, True, True, True, 0, 0, False)

As a result, the program can automate the process of solid creation such as in

Figure 6.36.

6-38

Figure 6.36: Generated part after the program modification

Programming modification: user input

Based on the previous program, the users are required to input these variables:

i) Coordinates of the the bottom left corner of the outer profile; P(1).x

and P(1).y

ii) length and height of the outer profile; L and H

iii) the radius of the inner circle; R

iv) height of the extrusion; extHeight

To allow the user, user input interface can be used. Following shows the code to create the user input and its explanation is graphically demonstrated in Figure 6.37.

Dim Message, Title, Default

Message = "Please key in your P(1).x is " Title = "InputBox" Default = "0.0" P(1).x = InputBox(Message, Title, Default)

6-39

Figure 6.37: Variables for user input function

If the user is not key in any value, default value is set to the respective variable.

Similar, user input interface can be applied to other inputs. The codes are shown in the following

Message = "Please key in your P(1).y is " Title = "InputBox" Default = "0.0" P(1).y = InputBox(Message, Title, Default)

Message = "Please key in the Length of the outer profile: " Title = "InputBox" Default = "10.0" L = InputBox(Message, Title, Default)

Message = "Please key in the Height of the outer profile: " Title = "InputBox" Default = "10.0" H = InputBox(Message, Title, Default)

Message = "Please key in the Radius of the inner circle: " Title = "InputBox" Default = "3" R = InputBox(Message, Title, Default)

Programming modification: error prompting

The next stage is to allow the program to prompt any error if any. When there is an error, it allows the user to input a new input. In this case, the possible error is when the radius of the circle is equal or larger than the shortest side of the outer boundary.

Therefore the radius must be less than half of the side length.

6-40

The suitable conditional statement used here is IF-THEN-ELSE. The first conditional statement is to set the smallest length of the perimeter and the second conditional statement is to ensure the radius must be less than halve of the smallest length. If it is not, error will be prompted and ask the user to input again the radius of the circle.

The basic IF-THEN-ELSE statement will be as the following:

If Ans =1 Then … (statement for TRUE) End If

The nested IF-THEN-ELSE statement will be as the following

If Ans1 = 1 Then … (statement for TRUE) Else If Ans1 = 2 Then … (statement for TRUE for Else if) Else … (statement for FALSE) End If

Hence, the additional code will be as the following.

Dim Min_length As Double

Min_length = Val(L)

If Val(L) > Val(H) Then Min_length = Val(H) End If

Min_length = 0.5 * Min_length

If R = Min_length Or R > Min_length Then

Dim Style, Response

6-41

Message = "The cirlce is larger than the outer profile" Title = "Msg Box" Style = vbOKOnly Response = MsgBox(Message, Style, Title)

Message = "Please key in new radius" Title = "InputBox" Default = Min_length - 0.1 R = InputBox(Message, Title, Default) End If

6.3.3 Tips to write good program

Following will give tips to write a good program. These tips will make the program easy to read.

1) Write note along with the code

Writing a note together with the source code is a good practice to keep track of

what has been written. In VBA, by writing single quote ‘, it will indicate the

line after the ‘ is non-executable line or it can be used as to write note.

If Val(L) > Val(H) Then ‘ if H is smaller than Min_length = Val(H) End If

2) Use tab to differentiate between segments

The whole program comprises of a number of segments. For example, in the ‘if’

statement, the segment starts with the word ‘if’ and ends with the word ‘end if’.

Therefore, to make the segment more traceable, the whole if statement can be

segmented using margin or tab as demonstrated in the following.

6-42

3) Fully utilization of global and local declaration

Global and local declaration plays an essential role in programming. Variables

that should be declared using global declaration, are the variables that have been

used repetitively throughout the program and its subfunctions. Examples of

variables are pi, gravity etc.

4) Write short source code with a number of functions

When a long program is written using only the main function, it will be difficult

to comprehend. Therefore, the solution of long programming is to have a

number of functions. The functions can be divided based on task. Following

shows samples of pseudo code with a number of functions.

Sub Main() func1() func2() …

6-43

End Sub

Function func1() … End Function

6.3.4 Case Studies

This section will show two case studies. The first case study will demonstrate the application of API when the part is based on equation and user can easily model the part by key in the main parameter. The second case study is to demonstrate the utilization of the part in engineering application.

Case Study 1: Modelling based on equations

In this case study, modelling of upper part of human body is used. Based on the anthropometric data [ref], all the human parts can be modelled based on the height of the person. Figure 6.38a shows the data from anthropometric data of the human upper part based on height H and Figure 6.38b shows upper part of human body model that is formed based on the equation.

6-44

Figure 6.38: Anthropometric data (aslam thesis)

All the parts can be drawn using API programming and then they can be assembled. As a result, model of human body can be drawn as shown in Figure 6.39 where three human body model with height 1.6 m, 1.7 m, and 1.8 m. Then, with this human body, further study based on ergonomic data can be carried out as such the demonstrated in Figure 6.40 to set the convenient dimensional for office furniture. As such, dimension A, C, and D can be used to set the dimension for the shelf, whilst dimension G and H can used to set the height of the chair.

Figure 6.39: Various height of human body

6-45

Figure 6.40: Setting the convenient parametric study for office for office furniture b) Recognition the features on the part

Model is created based on the combination of features. These features are considered as a design or machining feature. Sample of design features are rib, protrusion, etc, whilst the sample machining features are slot, hole, etc. Design features are used during modelling process and machining features are used during machining process.

Some of the design features have opposite characteristic to machining features. As such, when a extruded feature is cut from the part, the process to machine can be directly assumed as the machining of similar volume. This is contradicted when the extruded feature is added to the part, machining process cannot add the feature to the part. Therefore, there is a need to convert these types of design features to equivalent machining volumes. The machining volumes can be regarded as machining features. Figure 6.41 shows samples of design features and their equivalent design features.

6-46

Figure 6.41: Samples of protrusion features and their equivalent machining features

API programming is used to develop the feature conversion system. The program must be able to read the BReps data of the model and translates the information into meaningful machining features.

The foundation of the searching process is the profiles that will form the extruded feature either as additional or cut feature. Therefore, the search process starts with the search of inner loop on the features. Figure 6.42 shows the framework to identify the machining features.

6-47

Figure 6.42: Framework to identify the machining features.

Figure 6.43 and 6.44 show the capability of feature conversion system to identify the machining features from isolated, nested, and interacting features.

Figure 6.43: Illustrative Sample 1

6-48

Figure 6.44: Illustrative Sample 2

6.4 APPLICATION 4: DESIGN WONDER

The engineering applications based on CAD has no limit. Engineering applications on

CAD can be enhanced until it has its own intelligence. The intelligence will make the computer be able to interpret the model into meaningful entity.

In the early 2000, MIT AI Laboratory has successfully developed an intelligent system called ASSIST. ASSIST is a system that has the capability to interpret human sketch into meaningful component and applied physic to simulate the movement. ASSIST is able to read the image from human sketch even there is a minor error on the sketch. Then, ASSIST converts the images into 2D geometrical

6-49

model and based on the geometry of the model, simulation can be done that is governed by rule of physics.

This is demonstrated as in Figure 6.45. Firstly, human will draw the situation

(Figure 6.45a). In this case, there is an error on sketch of the platform which the platform is not even. Then the system will translate the image into geometrical model and at the same time the human error will be handled by the system (Figure 6.45b).

When the button ‘RUN’ is pressed, based on the law of physics, the simulation is carried out. The car will move downward based the downward arrow to show the gravitational force. The crossed symbol will make the platform to be fixed and make the car to travel on the platform. The simulation is carried out and even the car will fall as it travels until it reaches the edges of the platform (Figure 6.45c).

Figure 6.45: Intelligent system that (a) read human sketch, (b) convert into

meaningful component, and (c) simulate the movment

With the principle of the ASSIST, MAGIC PAPER system is developed and a software Physic Illustrator was developed by MIT and Microsoft. Even, this may be the future of the CAD based project which have intelligence to bring the implementation of CAD at the very early stage of design.

The foundation of the intelligence of the system is the reasoning on geometry of the entities. Since all the entities are represented by its geometry and topology, the reasoning to convert these low level entity representation into meaningful human

6-50

perception. As such, a square is described by its low level representation of four lines that have start and end points. Based on the topology and geometry data, the computer is able to perceive the profile is square when the connectivity of lines can be formed and the length of all the edges are equal. The level of reasoning can vary by simply checking the coordinates of the end points of the lines or using the graph theory to identify the incident vertices and the adjacent lines.

In the following, examples will demonstrate the geometric reasoning used to create an intelligent system

Example 6.4: Recognition of types of triangles

Figure 6.46 shows four types of triangles which are acute, obtuse, equilateral, and isosceles. Assume these triangles are drawn using 2D wireframe and your task is to develop the geometric reasoning that can be implemented to distinguish the type of triangle.

Figure 6.46: Types of triangles

Solution

Step 1: Low-level 2D wireframe representation

A 2D triangle is represented by three lines. Based on the wireframe representation, the stored data are as the following

6-51

Line 1: L1 with (x1, y1) and (x2, y2),

Line 2: L2 with (x2, y2) and (x3, y3)

Line 3: L3 with (x1, y1) and (x3, y3)

Based on these data, each line is treated as separate entity and even there is no information on the connectivity of the lines.

Step 2: Characteristics of the triangle

The characteristics of the triangles are as the following

Acute: when all the angle of vertices are less than 90o

Obtuse: when there is one vertex that has angle is larger than 90o

Right: when there is one vertex that has the angle is equal to 90o

Equilateral: when all the vertices have the equal angles of 60o.

Isoceles: when two of the angles are equal and the other angle can be smaller

or larger than 90o.

Step 3: Development of the geometric reasoning

Since it is 2D wireframe entity, all the lines are treated individual data without any connectivity. Therefore, the connectivity of the lines must be identified first.

Heuristics reasoning based on the observation that when two points for two lines are equal, both lines are adjacent to each other and the point will the incident vertex.

The first line detected, both end points of the line will contribute the first vertex v1 and second vertex v2 of the triangle. Therefore, the next step is to check the other and the third vertex v3 is the end point that is not equal to the either v1 or v2.

Therefore, the pseudo programming will be as the following:

6-52

v1 = L1.p1

v2 = L1.p2

if (L2.p1 is not equal to L1.p1 AND L1.p2 )

v3 = L2.p1

else v3 = L2.p2

Then, dot product will be applied to calculate the angle bounded by the

incident edges of the vertex. Dot product as in equation 6.1 is used to calculate the

angle and graphically it is demonstrated by Figure 6.47.

Figure 6.47: Dot product

a.b  a b cos()  a.b  (6.1)   cos1     a b 

Using Equation 6.1, all the angles on the triangle can be calculated. Therefore,

the following rule can be used to identify the triangle.

If (all the angles = 60o) triangle = equilateral

Else if (one of the angles = 90o) triangle = right

Else if (two of the angles are equal) triangle = isosceles

6-53

Else if (none of the angle is larger than 90o) triangle = acute

Else triangle = obtuse

This geometric reasoning is one of the possible solutions. There are other geometric reasoning can be implemented and still can identify the triangle. However, the isosceles must be identified first prior to identification of obtuse triangle. This because isosceles triangle can also be categorized as obtuse triangle if one the angle is larger than 90o.

Example 6.5: Simple bouncing ball

A ball drops from h height is governed by the following equation.

Potential energy at height h = mgh

Kinetics energy when the ball reaches the floor = 1/2 m v2.

Therefore v = ( g h ) 0.5

Your task is to animate the physical simulation of the ball dropping until it stops. Assume that 15% of the energy is lost when the ball hits the floor (refer Figure

6.48).

Answer the following problem: a. Write the computer representation of the ball and ground. (Assume: the ball

will be a circle and the ground is just a line ) b. What do you expect in the simulation? c. Discuss the geometric reasoning and programming procedure in developing

this simulation based on the computer representation in (a).

6-54

Figure 6.48: Ball dropping examples

Solution

( a )

The ball is represented as circle and the circle is represented by its center point ( xc, yc) and radius. The ground is represented by line with two end points (x1, y1) and

(x2, y2)

( b )

When the ball dropped, it will bound back but due to the energy lost, the ball will reach 0.85 of the original height. The process continues until h approaches zero.

However mathematically the final h cannot reach 0, therefore assumption has to make that if h is less than one value (i.e 0.01), h will set to 0.

( c )

Firstly calculate the initial height h.

h = yc – y1 – r

where yc: y coordinate of the circle

6-55

y1: y coordinate of the line

r: radius of the circle

Then, time to reach for the ball to reach should be calculated.

v  u t  max g

Therefore simulation can be done by every delta t (t)

For every t, calculation of the position of the ball is shown Table 6.1

Table 6.1: Calculation of the coordinates of the circle at time ti for downward

position

Time 1st iteration 2nd iteration … Nth iteration t0 = 0 … Velocity v0 = 0 = u v0 = 0 = u v0 = 0 = u Delta h h = 0 h = 0 h = 0 Height h0 = h h0 = 0.85h h0 = (0.85)N-2 h Coordinates ( xc , h0 + r ) ( xc , h0 + r ) ( xc , h0 + r ) t1= t +t Velocity v1 = g(t1) Delta h h = 0.5g(t1)2 Height h1 = h0 - h Coordinates ( xc, h1 + r)

… … t(i-1)= t +(i-1)t Velocity v(i-1) = g(t(i-1)) Delta h h = 0.5g(t(i-1))2 Height h(i-1) = h0 - h Coordinates ( xc, h(i-1) + r)

6-56

t(i) = tmax Velocity v(i) = g(t(i)) Delta h h = h Height h(i) = 0 Coordinates ( xc, h + r)

The geometric reasoning is the calculation involved to find the center of the circle at time ti. When the ball rebounce, the position of the ball goes upward t(i_upward) is equal to the position of the ball goes downward at t(i- i_downward).

Therefore the programming procedure is as follows

While ( h > 0.01 ) Set the value of t and I equal 0 Calculate the max velocity Vmax = (g * h )^0.5 Calculate the tmax tmax = vmax/g Number of iteration N_iter = int ( tmax/Dt) If ( direction == downward ) For ( i = 0; I < N_iter; i++) Calculate the center point here Draw the circle based on the center point t = t + Dt End For Else if For ( i = N_iter - 1; I < N_iter; i--) Calculate the center point here Draw the circle based on the center point t = t + Dt End For End if Setting the value h for the next iteration h = 0.85h End while

6-57