23
[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com [100] 013 revised on 2012.10.28 cemmath The Simple is the Best Chapter 13 Vertex and Coordinate System 13-1 Class ‘vertex’ 13-2 Operations for Vertices 13-3 Member Functions for Vertices 13-4 Class ‘csys’ 13-5 Application Examples 13-6 Summary The class ‘vertex’ is very useful in handling geometry in the three-dimensional space. For example, mesh generation can be carried out by using vertex arrays. This leads to an introduction of another important data type ‘csys’ which represents a coordinate system. In this chapter, we discuss data types of ‘vertex’ and ‘csys’. Section 13-1 Class ‘vertex’ Data Structure of Vertex. The vertex in two- dimension or in three-dimension is defined as 1

 · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

Embed Size (px)

Citation preview

Page 1:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

[100] 013 revised on 2012.10.28 cemmath

The Simple is the Best

Chapter 13 Vertex and Coordinate System

13-1 Class ‘vertex’13-2 Operations for Vertices13-3 Member Functions for Vertices13-4 Class ‘csys’13-5 Application Examples13-6 Summary

The class ‘vertex’ is very useful in handling geometry in the three-dimensional space. For example, mesh generation can be carried out by using vertex arrays. This leads to an introduction of another important data type ‘csys’ which represents a coordinate system. In this chapter, we discuss data types of ‘vertex’ and ‘csys’.

Section 13-1 Class ‘vertex’

■ Data Structure of Vertex. The vertex in two-dimension or in three-dimension is defined as

v=i x+ j y , v=i x+ j y+k z

where i , j , k are the unit vectors in the Cartesian coordinates, and z=0 is assumed in two-dimensional space. In Cemmath, the vertex is denoted by

v = < x, y > v = < x, y, z >

1

Page 2:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

where x , y , z

are double data. In Cemmath, all the vertex data are stored as the

three-dimensional data. The default format for displaying vertices is

“< %12.4g %12.4g %12.4g >”

which can be changed by

vertex.format(“string”)

This can be confirmed by the following Cemmath commands

%> default display #> x = 1;; y = pi;; z = sqrt(2);; #> v = <x,y,z>;#> vertex.format(" %15.6e, %15.6e, %15.6e"); v;#> vertex.format("< %12.4g %12.4g %12.4g >"); v;v = < 1 3.142 1.414 >v = 1.000000e+000, 3.141593e+000, 1.414214e+000v = < 1 3.142 1.414 >

■ Writing Coordinate System. The principal coordinate systems are the Cartesian (rectangular), cylindrical and spherical coordinate systems. The polar coordinate system is considered to be the cylindrical coordinate system with z=0. The global Cartesian coordinate is the default coordinate and is designated

<x,y,z, rec>

which is the same as

<x,y,z> // the default writing system is always Cartesian

The polar coordinate (r , θ )

or the cylindrical coordinate (r , θ , z)

defined as

x=r cosθ , y=rsin θ

2

Page 3:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

can be applied to write a vertex

< r,t, cyl > < r,t,z, cyl > // this is the standard form

Also, the spherical coordinate (r ,φ , θ ) defined as

x=r sinφ cosθ , y=r sinφ sinθ , z=rcos φ

can be utilized to write a vertex

< R,P,T, sph > // this is the standard

■ Reading Coordinate System. Any point in the global Cartesian coordinate can be read from the cylindrical and spherical coordinate systems by

< x,y,z >.cyl< x,y,z >.sph

to get (r , θ , z ) and (r ,φ ,θ ) values. For example,

#> < 1,1,1 >.cyl ;#> < 1,1,1 >.sph ;

result in

ans = < 1.414 0.7854 1 >ans = < 1.732 0.9553 0.7854 >

At present, it is noteworthy that the angle is written in radian instead of degree. Of course, such a regulation can be easily changed as can be seen later.

■ Conversion between Coordinate Systems. Any vertex written in one coordinate system can be converted to a vertex in another coordinate system by

< double,double,double, w_csys > .r_csys< vertex, w_csys > .r_csys< double,double,double, wA_csys[i] > .rA_csys[j]< vertex, wA_csys[i] > .rA_csys[j]

3

Page 4:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

where w_csys represents a writing coordinate system, and r_csys a reading coordinate system. In addition, wA_csys represents an array of ‘csys’. Then, one can easily note that whenever the writing and reading coordinate systems are identical, e.g.

< double,double,double, w_csys > . w_csys< double,double,double, wA_csys[i] > . rA_csys[j]

are always the same as

< double,double,double >

The notation in Cemmath is very concise and thus will help users to exploit various coordinate systems with ease.

■ Coordiate Values. Any vertex can be interpreted in one of the Cartesian, cylindrical/polar and spherical coordinates. In Cemmath, the specific coordinate values are designated

v.x, v.y, v.z // ( x, y, z ) for the Cartesian coordinate v.r, v.t, v.z // ( r, t, z ) for the cylindrical coordinate v.R, v.P, v.T // ( R, P, T ) for the spherical coordinate

It should be noted that the angle system is by default ‘csys.rad’ based on the radian system in both reading and writing modes. The angle system can be changed by employing degree coordinate system, i.e. ‘csys.deg’ as can be seen later. An example is as follows.

%> coordinate values #> v = < 1,1,1 > ;#> v.x; v.y; v.z; // Cartesian#> v.r; v.t; v.z; // cylindrical#> v.R; v.P; v.T; // spherical v = < 1 1 1 >ans = 1ans = 1ans = 1ans = 1.4142136ans = 0.78539816ans = 1

4

Page 5:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

ans = 1.7320508ans = 0.95531662ans = 0.78539816 It is also possible to change the specific coordinate value. For example,

%> coordinate values #> v = < 1,1,1 > ;#> v.R = 3 ;v = < 1 1 1 >v = < 1.732 1.732 1.732 >

Note that changing the radius in the spherical coordinate does not change the azimuthal and the cone angles. This is true for all other coordinate values, i.e. only one spatial coordinate can be changed by component assignment in each coordinate system.

■ Compound Operations. Compound operations for the vertex elements are very useful to manipulate the positions at the three-dimensional space. For example, a vertex at (r , θ , z ) can be moved to (r , θ+Δθ , z ) just by ‘v.t += dt’. Available compound operations are

v.x += d v.x -= d v.x *= d v.x /= d v.x ^= dv.y += d v.y -= d v.y *= d v.y /= d v.y ^= dv.z += d v.z -= d v.z *= d v.z /= d v.z ^= dv.r += d v.r -= d v.r *= d v.r /= d v.r ^= dv.t += d v.t -= d v.t *= d v.t /= d v.t ^= dv.R += d v.R -= d v.R *= d v.R /= d v.R ^= dv.P += d v.P -= d v.P *= d v.P /= d v.P ^= dv.T += d v.T -= d v.T *= d v.T /= d v.T ^= d

Examples are

%> compound operations #> csys.rad; #> vx = < 2,0.5,1, sph >;; vx.sph ;#> v = vx;; v.R += 1;; v.sph ;#> v = vx;; v.P += 1;; v.sph ;#> v = vx;; v.T += 1;; v.sph ;vx = < 0.5181 0.8068 1.755 >ans = < 2 0.5 1 >ans = < 3 0.5 1 >

5

Page 6:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

ans = < 2 1.5 1 >ans = < 2 0.5 2 >

Section 13-2 Operations for Vertices

■ Binary Operations. Binary operations between vertices are discussed by using two vertices

a = < a1, a2, a3 >b = < b1, b2, b3 >

Then, binary operations between vertices are defined

a + b = < a1+b1, a2+b2, a3+b3 > = a .+ ba – b = < a1-b1, a2-b2, a3-b3 > = a .- ba * b = a1*b1 + a2*b2 + a3*b3a ^ b = < a2*b3-a3*b2, a3*b1-a1*b3, a1*b2-a2*b1 >

a .* b = < a1*b1, a2*b2, a3*b3 > // element-by-elementa .^ b = < a1^b1, a2^b2, a3^b3 >a ./ b = < a1/b1, a2/b2, a3/b3 >a . \ b = < b1/a1, b2/a2, b3/a3 >

Examples are

%> binary operations #> <1,2,3> + <3,4,5> ; ans = < 4 6 8 >

#> <1,2,3> * <3,4,5> ; ans = 26

#> <1,2,3> ^ <3,4,5> ; ans = < -2 4 -2 >

Note that multiplication of two vertices (i.e. 3D vectors) produces ‘double’ data not of ‘vertex’. Also, note that the hat ‘^’ operator corresponds to the cross product between vertices. These operations are consistent with the typical vector operations

a ⋅b=a1b1+a2b2+a3b3

6

Page 7:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

a×b=| i j ka1 a2 a3

b1 b2 b3|

¿ i (a2b3−a3b2 )+ j (a3b1−a1b3 )+k (a1b2−a2b1)

In particular, the relational operators are defined

a == b is true if |a1-b1|+|a2-b2|+|a3-b3| <= mepsa != b is true if |a1-b1|+|a2-b2|+|a3-b3| > mepsa > b is true if a1 > b1, a2 > b2, a3 > b3a < b is true if a1 < b1, a2 < b2, a3 < b3a >= b is true if a1 >= b1, a2 >= b2, a3 >= b3a <= b is true if a1 <= b1, a2 <= b2, a3 <= b3

where ‘meps’ is a priori prescribed small number. A few examples are as follows.

%> binary operations#> <1,2,3> == <3,4,5> ; #> <1,2,3> != <3,4,5> ; #> <1,2,3> > <3,4,5> ; #> <1,2,3> < <3,4,5> ; #> <1,2,3> >= <3,4,5> ; #> <1,2,3> <= <3,4,5> ;ans = 0ans = 1ans = 0ans = 1ans = 0ans = 1

■ Binary Operations with ‘double’ Data. Binary operations between vertices and double data are performed by upgrading ‘double’ to ‘vertex’, i.e. a double data is considered to be a vertex with all the identical components. In summary, bindary operations for vertices are listed as follows

v1 == v2 v1 == s s == v2v1 != v2v1 > v2

v1 != sv1 > s

s != v2s > v2

7

Page 8:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

v1 < v2v1 >= v2v1 <= v2

v1 < sv1 >= sv1 <= s

s < v2s >= v2s <= v2

v1 + v2 v1 + s s + v2v1 - v2 v1 - s s - v2v1 * v2 v1 * s s * v2v1 ^ v2 v1 / s s \ v2

v1 .+ v2 v1 .+ s s .+ v2v1 .- v2 v1 .- s s .- v2v1 .* v2 v1 .* s s .* v2v1 .^ v2 v1 .^ s s .^ v2v1 ./ v2 v1 ./ s v1 .\ v2 s .\ v2

■ Compound Operations. Compound operations for vertices are as follows.

v += v2v -= v2

v += sv -= s

v ^= v2 v *= s v /= s

■ Tensor Operations. Vectors in physics, e.g. force, can be also described by vertices in 3D space. In Cemmath, the second-order tensor in physics is treated as a 3×3 matrix. Then, two vertices, or equivalently two vectors

a = < a1, a2, a3 >b = < b1, b2, b3 >

can be used to define tensor product and tensor division

a ** b = [ a1*b1, a2*b1, a3*b1 ] [ a1*b2, a2*b2, a3*b2 ] [ a1*b3, a2*b3, a3*b3 ]

a %% b = [ a1/b1, a2/b1, a3/b1 ] [ a1/b2, a2/b2, a3/b2 ] [ a1/b3, a2/b3, a3/b3 ] These operators can be utilized to calculate, for example

8

Page 9:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

σ=d Fd A

=( dF jdA j )=[dF1

dA1

dF2

dA1

dF3

dA1

dF1

dA2

dF2

dA2

dF3

dA2

dF1

dA3

dF2

dA3

dF3

dA3

]since we can write the above as ‘dF %% dA’.

In addition, the typical multiplication in continuum mechanics such as ‘vector*tensor’ and ‘tensor*vector’ can be implemented in Cemmath

‘vertex’ * ‘matrix’ ‘matrix’ * ‘vertex’

which represent the following operations

d A ⋅σ=( i d A1+ jd A2+k d A3 )⋅ ( ii σ 11+ij σ12+ik σ 13+ ji σ21+ jj σ 22+ jk σ23

+kiσ 31+kj σ32+kk σ33)¿d A1¿

+d A3 ( i σ31+ j σ32+k σ33 )

σ ⋅d A=( ii σ11+ij σ12+ik σ13+ ji σ 21+ jj σ22+ jk σ23

+kiσ 31+kj σ32+kk σ33)⋅ ( id A1+ j d A2+k d A3)¿d A1¿

+d A3 ( i σ13+ j σ23+k σ33 )

An example for tensor operations is given below.

%> tensor operations#> I = < 1,0,0 >;; J = < 0,1,0 >;; K = < 0,0,1 >;;#> va = <1,2,3>; vb = <3,4,5>; va = < 1 2 3 >vb = < 3 4 5 >

9

Page 10:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

#> C = va ** vb ; C = [ 3 6 9 ] [ 4 8 12 ] [ 5 10 15 ]

#> D = va %% vb ; D = [ 0.33333 0.66667 1 ] [ 0.25 0.5 0.75 ] [ 0.2 0.4 0.6 ]

#> I * D; J * D; K * D; ans = < 0.3333 0.6667 1 >ans = < 0.25 0.5 0.75 >ans = < 0.2 0.4 0.6 >

#> D * I; D * J; D * K;ans = < 0.3333 0.25 0.2 >ans = < 0.6667 0.5 0.4 >ans = < 1 0.75 0.6 >

Section 13-3 Member Functions for Vertices

■ Member Functions. Avaliable member functions

.xrot(t) rotation around the x-axis

.yrot(t) rotation around the y-axis

.zrot(t) rotation around the z-axis

.xrotd(t) rotation around the x-axis in degree

.yrotd(t) rotation around the y-axis in degree

.zrotd(t) rotation around the z-axis in degree

.unit normalize by the magnitude

.trun truncate

.plot plot in 3D space

.abs/norm the same as .R

.symm(vp) symmetric position with respect to ‘vertex’ vp

are employed to treat vertices in a variety of ways.

Section 13-4 Class ‘csys’

10

Page 11:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

In this section, we discuss the class ‘csys’ to describe local coordinate system in contrast to the global coordinate systems.

■ Principal Coordinate Systems. The global principal coordinate systems (i.e. the rectangular, cylindrical and spherical) should be treated as special ‘csys’. This allows that

%> (M #Example 13-4-1) principal spherical system#> csys.sph;

to represent

ans = 'spherical' local coordinate system origin = < 0 0 0 > dir cosine = [ 1 0 0 ] [ 0 1 0 ] [ 0 0 1 ]

■ Local Coordinate Systems. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the second is the direction cosines. In the global Cartesian coordinate, the direction cosine of the x-axis of a local coordinate can be written as d1=(d11 , d¿¿21 , d31)¿. Similary, the y and z axes can be denoted

by d2=(d12 , d¿¿22 , d32)¿ and d3=(d13 , d¿¿23 , d33)¿, respectively. Also, the orthogonality requires that d i ⋅d j=δij whenever δ ij is the Kronecker delta.

Then, the mathematical definition of a local orthogonal coordinate system is

[XYZ ]=[ x0

y0

z0]+[d11 d12 d13

d21 d22 d23

d31 d32 d33][ xyz ]

where the origin of a local coordinate system is represented by a vertex, and the direction cosine of a local coordinate system is represented by a matrix of dimension 3×3. Then, the coordinate (x , y , z) in the local coordinate can be

identified as the coordinate (X ,Y ,Z ) in the global Cartesian coordinate.

11

Page 12:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

The syntax to create a local coordinate system with an origin at vertex ‘vorg’ is

csys.rec ( vorg, vn1,vn2 )csys.cyl ( vorg, vn1,vn2 )csys.sph ( vorg, vn1,vn2 )

or equivalently

csys ( 1, vorg, vn1,vn2 )csys ( 2, vorg, vn1,vn2 )csys ( 3, vorg, vn1,vn2 )

where the integers 1,2 and 3 denote the rectangular, cylindrical and spherical coordinate, respectively. In the above, two vertices ‘vn1,vn2’ are used to generate direction cosines

d1=n1

|n1|, d2=

n1×n2

|n1×n2|, d2=d3×d1

■ An Example of Local Coordinate Systems. Let us consider a simple example of a local coordinate system by the following Cemmath command

%> local coordinate system #> cs1 = csys.cyl( <3,1>, <1,1>, <-1,2>);cs1 = 'cylindrical' local coordinate system origin = < 3 1 0 > dir cosine = [ 0.70711 -0.70711 0 ] [ 0.70711 0.70711 0 ] [ 0 0 1 ]

This local coordinate system is shown in Figure 1.

12

Page 13:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

Figure 1 A local coordinate system

Then, it is easy to find that the point P(1,1,0) in the global coordinate is interpreted to be (2,3 π / 4,0) in the local cylindrical coordinate system. Also the point Q(2,2,0) in the global coordinate is interpreted to be (√2 , π / 2,0) in the local cylindrical coordinate system. This can be confirmed by

#> <1,1,0>.cs1 ; // <2, pi*3/4, 0>#> <2,2,0>.cs1 ; // <1.414, pi/2, 0> #> <sqrt(2),pi/2,0, cs1> ; // <2, 2, 0>ans = < 2 2.356 0 >ans = < 1.414 1.571 0 >ans = < 2 2 0 >

In the above, writing and reading with respect to a local coordinate system are treated very concisely.

■ Class Functions of ‘csys’. Several class functions are

csys.rec // csys.rectangular, csys.cart, csys.cartesian csys.cyl // csys.cylindrical, csys.polar csys.sph // csys.spherical csys.deg // angles in degree csys.rad // angles in radian (default) csys.pass180/passpi // pass 180 degree, i.e. 0 <= theta < 360 csys.pass0 // pass 0 degree, i.e. -180 < theta <= 180

13

Page 14:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

When ‘csys.deg’ is executed, the degree is adopted to be the angle system. This can be confirmed by

%> angle system #> csys.deg; < 1,45,0, cyl >;#> csys.rad; < 1,pi/4,0, cyl >;// angle in degree. csys.deg is activatedans = < 0.7071 0.7071 0 >// angle in radian. csys.rad is activatedans = < 0.7071 0.7071 0 >

The range of angle can be defined in two different ways

0≤θ<2π ,−π<θ≤π

The first case passes θ=π line and the second case passes θ=0 line. In this regard, two commands ‘csys.pass180/passpi’ and ‘csys.pass0’ can be used to select the range of angle. The default system is ‘csys.pass0’, i.e. −π<θ≤π is assumed. This argument can be confirmed by

%> angle range #> csys.pass180; < 1,-1,0 >.cyl;#> csys.pass0; < 1,-1,0 >.cyl;// angle range, 0 <= radian < 2*pi is activatedans = < 1.414 5.498 0 >// angle range, -pi < radian <= pi, is activatedans = < 1.414 -0.7854 0 >

■ Member Functions of ‘csys’. Several member functions are

.plot // plot coordinate system .org // origin of a local coordinate system .cos // direction cosine of a a local coordinate system

The origin of a local coordinate system can be changed via member function ‘org’. An example is as follows.

%> change origin#> cs2 = csys.cyl( <3,1>, <1,1>, <-1,2>);#> cs2.org = < 5,4,7 >;#> cs2;

14

Page 15:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

cs2 = 'cylindrical' local coordinate system origin = < 3 1 0 > dir cosine = [ 0.70711 -0.70711 0 ] [ 0.70711 0.70711 0 ] [ 0 0 1 ]ans = < 5 4 7 >cs2 = 'cylindrical' local coordinate system origin = < 5 4 7 > dir cosine = [ 0.70711 -0.70711 0 ] [ 0.70711 0.70711 0 ] [ 0 0 1 ]

However, direction cosine cannot be modified since the orthogonality of the direction cosine need to be preserved. In later version of Cemmath, we will upgrade this part. Referring can be done by

%> change origin #> cs2 = csys.cyl( <3,1>, <1,1>, <-1,2>);#> cs2.cos;ans = [ 0.70711 -0.70711 0 ] [ 0.70711 0.70711 0 ] [ 0 0 1 ]

Section 13-5 Application Examples

■ Center of a Triangle. A circle enclosing a triangle is found by vertex operations as follows.

%> A circle enclosing a triangle #> vA=<3,5,7>; vB=<-1,2,-5>; vC=<4,-6,1>; #> Radius = 0;#> vG=(vA+vB+vC)/3; // geometric center

va = vB-vA; vb = vC-vA; vn = va^vb; vx = vn^va;

15

Page 16:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

dt = 0.5*((vb-va)*vb)/(vx*vb); vr = 0.5*va+dt*vx; // vr = va/2+t*vx, vr-(vb/2) should be orthogoanal to vb

if(Radius > 1.e-10) { dt = sqrt( (Radius*Radius-vr*vr)/(vn*vn) ); vr = vr + dt*vn; }

#> vcen = vA+vr ;#> (vcen-vA).abs;#> (vcen-vB).abs;#> (vcen-vC).abs ; // 7.11111vcen = < 1.99 0.8125 1.342 >ans = 7.1111817ans = 7.1111817ans = 7.1111817

At the end of commands, it is confirmed that the point ‘vcen’ is indeed the center of a triangle.

■ Array of Vertex. A number of vertices can be created by an array of vertex, and they can be used to generate meshes. An example is to make an annular mesh as follows.

%> Vertex array to generate annular mesh #> vertex V[50];#> csys.deg;#> for.i(0,4) { r = 1 + 0.1*i;; for.j(0,9) { t = 36*j;; V[10*i+j] = < r,t, cyl >;; } }#> V;V = vertex [50] [0] = < 1 0 0 > [1] = < 0.809 0.5878 0 > [2] = < 0.309 0.9511 0 > [3] = < -0.309 0.9511 0 > …

[18] = < 0.3399 -1.046 0 > [19] = < 0.8899 -0.6466 0 >

16

Page 17:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

and more ... (50 elements)

Section 13-6 Summary

■ Class Functions of ‘vertex’.

vertex.format(“string”)

■ Conversion between Coordinate Systems. Any vertex written in one coordinate system can be converted to a vertex in another coordinate system by

< double,double,double, w_csys > .r_csys< vertex, w_csys > .r_csys

■ Member Functions of ‘vertex’.

.xrot(t) rotation around the x-axis

.yrot(t) rotation around the y-axis

.zrot(t) rotation around the z-axis

.xrotd(t) rotation around the x-axis in degree

.yrotd(t) rotation around the y-axis in degree

.zrotd(t) rotation around the z-axis in degree

.unit normalized by the magnitude

.trun truncate

.plot/plot3 plot in 3D space

.abs/norm the same as .R

.symm(vp) symmetric position with respect to ‘vertex’ vp

■ Class Functions of ‘csys’.

csys.rec // csys.rectangular, csys.cart, csys.cartesian csys.cyl // csys.cylindrical, csys.polar csys.sph // csys.spherical csys.deg // angles in degree csys.rad // angles in radian (default) csys.pass180/passpi // pass 180 degree, i.e. 0 <= theta < 360 csys.pass0 // pass 0 degree, i.e. -180 < theta <=180

csys.rec ( vorg, vn1,vn2 )csys.cyl ( vorg, vn1,vn2 )csys.sph ( vorg, vn1,vn2 )

17

Page 18:  · Web view. A local coordinate system is composed of two elements with respect to the global Cartesian coordinate. The first is the origin, and the …

[100] 013 Chapter 13 Vertex and Coordinate System, Tutorial by www.msharpmath.com

■ Member Functions of ‘csys’.

.plot/plot3 // plot coordinate system .org // origin of a local coordinate system .cos // direction cosine of a local coordinate system

//----------------------------------------------------------------------// end of file//----------------------------------------------------------------------

18