VecPt2D Class Function Manual


(   )

| HOME | BACK |

Purpose

To get a value of an element at a particular index in a Vector.  The return result is a Pt2D object.

The first element index is 0, and the last one is n-1, where n is no of total elements.

Class

VecPt2D

Usage

{Pt2D} ret  =  object({int} argm1)

argm1 = index number

Example:

->v = VecPt2D(5)

->v.pushback(Pt2D(10,20))

->v.pushback(Pt2D(20,30))

->v.pushback(Pt2D(30,40))

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)

->v(0)

ans
= ( 10.000 , 20.000)

->

See also (class function)

init

| HOME | BACK |


AREA

| HOME | BACK |

Purpose

To compute area of a polygon, sequentially constructed by all points in the calling object.

Class

VecPt2D

Usage

{double} ret = object.AREA()

Example:

->v = VecPt2D(5)

->v.pushback(Pt2D(10,20))

->v.pushback(Pt2D(20,30))

->v.pushback(Pt2D(300,40))

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 300.000 , 40.000)

->v.area()

ans
= 1350.00000

->

See also (class function)

 

| HOME | BACK |


DEG

| HOME | BACK |

Purpose

To convert the values of X Y coordinates from degree minute second in the DD.MMSSSSS format to decimal point degree.  The result is stored to another VecPt2D object.   

Class

VecPt2D

Usage

{VecPt2D} ret  =  object.DEG([{int} argm1])

argm1 =  flag option (1 = only convert the X coordinate 

                               2 = Only convert the Y coordinate

                     all other numbers (default) = convert both X and Y coordinates

Example:

->print v

Vec of 2D Point...

list id : 0

Vector size : 2

( 1.500 , 2.400)
( 1.500 , 2.400)



->v1 = v.deg()
->print v1

Vec of 2D Point...

list id : 0

Vector size : 2

( 1.833 , 2.667)
( 1.833 , 2.667)

->

See also (class function)

dms

| HOME | BACK |


DMS

| HOME | BACK |

Purpose

To convert the values of X coordinates,  from decimal degree to degree minute second in the DD MM SS.SSS format.  The result is stored to another VecStr object.   

Only X coordinates of the vector are converted and stored.  If you want Y coordinates to be converted too, you can swap the coordinates in the vector and do the function one more time

Class

VecPt2D

Usage

{VecStr} ret  =  object.DMS({int} argm1)

argm1 = no of decimal points of the value of second. (default = 1)

Example:

->print v

Vec of 2D Point...

list id : 0

Vector size : 2

( 1.500 , 2.400)
( 1.500 , 2.400)



->v2 = v.dms(5)
->print v2

Vector size : 2

1 30 00.00000
1 30 00.00000

->

See also (class function)

deg

| HOME | BACK |


 

EXTEND

| HOME | BACK |

Purpose

To increase the maximum size of the vector by a given number.

Class

VecPt2D

Usage

{void} object.EXTEND({int} argm1)

argm1 = number of elements wanted to extend

Example:

->v = VecPt2D(5)

->v.maxsize()

  ans
= 5

->v.extend(500)

->v.maxsize()

  ans
= 505

->

See also (class function)

maxsize, truncate

| HOME | BACK |


FIND

| HOME | BACK |

Purpose

To find in a vector object a particular value of element.  This function only compares the ID number of points.  It does not take into account values of x y coordinates.

The return result is an index of the vector, if found, otherwise it returns -1.

Class

VecPt2D

Usage

{int} ret  =  object.FIND({IdPt2D} argm1)

argm1 = value of an element wanted to find

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)

->v.find(Pt2D(20,30))

ans
= 1

->

See also (class function)

qfind

| HOME | BACK |


ID

| HOME | BACK |

Purpose

To report the current ID of the vector.

Class

VecPt2D

Usage

{int} ret  =  object.ID()

Example:

->v = VecPt2D(5)

->v.id()

  ans
=   0

->

See also (class function)

maxsize, truncate, extend

| HOME | BACK |


INIT

| HOME | BACK |

Purpose

To initialize a vector object. 

Please be aware that once the vector is initialized, it is still empty.  Only its maximum number of element in the vector is declared.  Use function "pushback" to insert element into a vector.

Class

VecPt2D

Usage

{void} object.INIT({int} argm1)

argm1 = number of maximum elements in the vector

Example:

->v = VecPt2D()

->v.init(500)

->

See also (class function)

pushback

| HOME | BACK |


LOAD

| HOME | BACK |

Purpose

To read data from an ASCII file and stored in a VecPt2D object.

If file name extension is omitted, the function will add default extensions to the files.  The default extension of an ASCII data file is ".txt".

Unless the path name is given in the file names, the function will search for the files in the current working directory, defined by command "set path".

It is important to make sure that the each line in the file has exactly 2 fields, the first is x coordinate and the second is y coordinate.  They are separated by at least one blank, a white space, ASCII 32.

It is possible to have a comment line in the data file, by inserting a slash sign, "/", in front of a line.  Comment lines will not be read by the function.

Class

VecPt2D

Usage

{void} object.LOAD({String} argm1)

argm1 = data filename (default extension is ".txt")

Example:

->v = VecPt2D()

->v.load("my_data")

->

See also (class function)

save

| HOME | BACK |


LOADSCH

| HOME | BACK |

Purpose

To search for a particular ID block number, then read a block of data out from an ASCII file and stored in a VecPt2D object.

If file name extension is omitted, the function will add default extensions to the files.  The default extension of an ASCII data file is ".txt".

Unless the path name is given in the file names, the function will search for the files in the current working directory, defined by command "set path".

Each line in the data file can either has one field or two fields.  If it has 2 fields, they are separated by at least one blank, a white space, ASCII 32, and the first one is read as row number, while the second one is column number.  A line with one field is interpreted as an ID.

An example of data is:

/ an example of data store in a file

101

10.000  20.000

20.000  30.000

30.000  40.000

102

15.000  20.000

16.000  30.000

17.000  40.000

103

16.000  20.000

/...

/... more

 

By using this function "loadsch", it is possible to store separate sets of data in one file, and be able to extract a particular data set within that file.  Each data set must have its own unique ID, for example 101, 102, 103 (see example above).

It is possible to have a comment line in the data file, by inserting a slash sign, "/", in front of a line.  Comment lines will not be read by the function.

Class

VecPt2D

Usage

{void} object.LOADSCH({String} argm1, {int} argm2)

argm1 = data filename (default extension is ".txt")

argm2 = Block ID (default is the calling vector block ID)

Example:

->v = VecPt2D()

->v.loadsch("my_data", 101)

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)




->

See also (class function)

load

| HOME | BACK |


MATRIX

| HOME | BACK |

Purpose

To convert to a Matrix object. 

This function creates a Matrix of size n rows by 2 columns, where n is number of indices in the vector.

Class

VecPt2D

Usage

{Matrix} ret  =  object.MATRIX()

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)

->M = v.matrix()

->print M


no of row
: 3
no of column
: 2

0
: 10.00000 20.00000
1
: 20.00000 30.00000
2
: 30.00000 40.00000

->

See also (class function)

 

| HOME | BACK |


MAX

| HOME | BACK |

Purpose

To compute the maximum value of elements in the vector.

The return result is a Pt2D object, where the x coordinate is the maximum value of x coordinates, and y coordinate is that of y coordinates.

Class

VecPt2D

Usage

{Pt2D} ret  =  object.MAX()

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)

->v.max()

ans
= ( 30.000 , 40.000)

->

See also (class function)

min, mean

| HOME | BACK |


MAXSIZE

| HOME | BACK |

Purpose

To report the maximum size of the vector.  This is the maximum number of elements that can be stored in the vector.

Class

VecPt2D

Usage

{int} ret  =  object.MAXSIZE()

Example:

->v = VecPt2D(5)

->v.maxsize()

  ans
=   5

->

See also (class function)

size, truncate, extend

| HOME | BACK |


MEAN

| HOME | BACK |

Purpose

To compute the mean value of indices in the vector.

The return result is a Pt2D object, where the x coordinate is the mean value of x coordinates, and y coordinate is that of y coordinates.

Class

VecPt2D

Usage

{Pt2D} ret  =  object.MEAN()

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)

->v.mean()

ans
= ( 20.000 , 30.000)

->

See also (class function)

min, max

| HOME | BACK |


MIN

| HOME | BACK |

Purpose

To compute the minimum value of elements in the vector.

The return result is a Pt2D object, where the x coordinate is the minimum value of x coordinates, and y coordinate is that of y coordinates.

Class

VecPt2D

Usage

{Pt2D} ret  =  object.MIN()

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)

->v.max()

ans
= ( 10.000 , 20.000)

->

See also (class function)

max, mean

| HOME | BACK |


NEAREST

| HOME | BACK |

Purpose

To search for points that are nearest to a given point.

Class

VecPt2D

Usage

{VecPt2D} ret = object.NEAREST({double} argm1,{double} argm2,{int} argm3)

argm1 = given x coordinate

argm2 = given y coordinate

argm3 = no of points being wanted

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)

->v.nearest(0,10,2)

ans
=
Vec of 2D Point
...

list id
: 0

Vector size
: 2

( 10.000 , 20.000)
( 20.000 , 30.000)

->

See also (class function)

 

| HOME | BACK |


PUSHBACK

| HOME | BACK |

Purpose

To insert an Pt2D in a vector object.  A new element will be insert at the last available index in the vector.

Suppose the vector has already 4 element in it, when a new element is inserted, the size is updated to 5 and the new element is stored at index number 4.  The first element index is 0, and the last one is n-1, where n is no of total elements.

Class

VecPt2D

Usage

{void} object.PUSHBACK({Pt2D} argm1)

argm1 = an 2D point being inserted

Example:

->v = VecPt2D(5)

->v.pushback(Pt2D(10,20))

->v.pushback(Pt2D(20,30))

->v.pushback(Pt2D(30,40))

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)

->

See also (class function)

init

| HOME | BACK |


QFIND

| HOME | BACK |

Purpose

To find in a vector object a particular value of element.  This function expects that the content of the vector is already sorted, or otherwise it will not work correctly.

It performs a binary searching which is much faster than using the function "find".

The return result is an index of the vector, if found, otherwise it returns -1.

Class

VecPt2D

Usage

{int} ret  =  object.FIND({Pt2D} argm1)

argm1 = value of an element wanted to find

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)

->v.qfind(Pt2D(20,30))

ans
= 1

->

See also (class function)

find

| HOME | BACK |


REMALL

| HOME | BACK |

Purpose

To empty the content of the vector. 

This function can be used to reset the vector very quick.  It simply sets the size of the vector to zero.  It does not do any memory initialization.

Class

VecPt2D

Usage

{void} object.REMALL()

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)
 

->v.remall()

->print v

->

See also (class function)

remove, remsort

| HOME | BACK |


REMOVE

| HOME | BACK |

Purpose

To remove an element at a particular index out of the vector.

This function replaces the content at the required index with the last element, and simply reduces the size of the vector by 1.

Class

VecPt2D

Usage

{void} object.REMOVE({int} argm1)

argm1 = index at which the element being removed

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)

->v.remove(0)

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 2

( 30.000 , 40.000)
( 20.000 , 30.000)

->

See also (class function)

remall, remsort

| HOME | BACK |


REMSORT

| HOME | BACK |

Purpose

To remove a group of elements, specified by a starting index and ending index, out of the vector.  This function will fill up the gap by shift the rest of the content of the vector forward.

Class

VecPt2D

Usage

{void} object.REMSORT({int} argm1,[{int} argm1])

argm1 = start index at which the element being removed

argm2 = ending index at which the element being removed

        (default = the same index as the start index)

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)

->v.remsort(0)

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 2

( 20.000 , 30.000)
( 30.000 , 40.000)



->

See also (class function)

remall, remove

| HOME | BACK |


REVERSE

| HOME | BACK |

Purpose

To reverse the order of the content of the vector.  The last point becomes the first element and the first point becomes the last element of the vector.

Class

VecPt2D

Usage

{VecPt2D} ret = object.REVERSE( )

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)

->v1 = v.reverse()

->print v1

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 30.000 , 40.000)
( 20.000 , 30.000)
( 10.000 , 20.000)

->

See also (class function)

remall, remove

| HOME | BACK |


SAVE

| HOME | BACK |

Purpose

To save as ASCII format.  Each line in the output file represents an element in the vector.

if a file name extension is not given, the function assumes an extension of ".txt".

if a path name is not include in the specified file name, the function will search in the current data path, set by command "set path".

Class

VecPt2D

Usage

{void} object.SAVE({String} argm1)

argm1 = output file name

Example:

->v.save("my_data")

->

See also (class function)

load, loadsch

| HOME | BACK |


SCALE

| HOME | BACK |

Purpose

To multiply coordinates of all point in the vector by constants.

Class

VecPt2D

Usage

{void} object.SHIFT({double} argm1,{double} argm2)

argm1 = scale in x direction    

argm2 = scale in y direction  

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 2

( 20.000 , 30.000)
( 30.000 , 40.000)

->v.scale(10,20)

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 2

( 200.000 , 600.000)
( 300.000 , 800.000)

->

See also (class function)

 

| HOME | BACK |


SHIFT

| HOME | BACK |

Purpose

To shift the coordinates by a specific amount in x and y direction.

Class

VecPt2D

Usage

{void} object.SHIFT({double} argm1,{double} argm2)

argm1 = shift in x direction    

argm2 = shift in y direction 

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 2

( 20.000 , 30.000)
( 30.000 , 40.000)

->v.shift(100,200)

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 2

( 120.000 , 230.000)
( 130.000 , 240.000)

->

See also (class function)

 

| HOME | BACK |


SIZE

| HOME | BACK |

Purpose

To report the current size of the vector.  This is the current number of elements in the vector.

Class

VecPt2D

Usage

{int} ret  =  object.SIZE()

Example:

->v = VecPt2D(5)

->v.size()

  ans
=   0

->

See also (class function)

maxsize, truncate, extend

| HOME | BACK |


SMOOTH

| HOME | BACK |

Purpose

To smooth a polyline.  The polyline is made up of all points of the calling vector as vertices.

The algorithm used here is Douglas-Peucker. 

The user is required to provide a tolerant distance, which is used to determine whether a vertex will be include in the smooth version of the line.  A vertex is discarded if the distance from it to the line is less than the given tolerance.

Class

VecPt2D

Usage

{VecPt2D} ret = object.SMOOTH({double} argm1)

argm1 = tolerant distance (in x y coordinate system unit)

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)

->v1 = v.smooth(1)

->print v1

Vec of 2D Point
...

list id :
0

Vector size
: 2

( 10.000 , 20.000)
( 30.000 , 40.000)

->

See also (class function)

 

| HOME | BACK |


SORT

| HOME | BACK |

Purpose

To sort elements of a vector by using Shell sort.

Elements in a vector are first sorted by their x coordinates.  If x coordinates are equal, they will be sorted by their y coordinates.

Class

VecPt2D

Usage

{VecPt2D} ret  =  object.SORT()

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 30.000 , 40.000)
( 20.000 , 30.000)
( 10.000 , 20.000)

->v1 = v.sort()

->print v1

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)

->

See also (class function)

qfind

| HOME | BACK |


SWAP_XY

| HOME | BACK |

Purpose

To swap x and y coordinates of all points in the vector.

Class

VecPt2D

Usage

{void} object.SWAP_XY()

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 30.000 , 40.000)
( 20.000 , 30.000)
( 10.000 , 20.000)

->v.swap_xy()

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 40.000 , 30.000)
( 30.000 , 20.000)
( 20.000 , 10.000)

->

See also (class function)

shift

| HOME | BACK |


TRUNCATE

| HOME | BACK |

Purpose

To trim out all the empty space of the current vector.

Suppose a vector has 5 elements in it, and its max size is 500, once it is trimmed, the max size is reduced to 5.  This function does a new memory initialization.

Class

VecPt2D

Usage

{void} object.TRUNCATE()

argm1 = number of elements wanted to extend

Example:

->v = VecPt2D(5)

->v.maxsize()

  ans
= 5

->v.truncate()

->v.maxsize()

  ans
= 0

->

See also (class function)

maxsize, extend

| HOME | BACK |


WINDOW

| HOME | BACK |

Purpose

To extract a portion of a vector, specified by a starting index and ending index.

Class

VecPt2D

Usage

{VecPt2D} ret  =  object.WINDOW({int} argm1,{int} argm2)

argm1 = start index at which the element being extracted

argm2 = ending index at which the element being extracted

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 40.000 , 30.000)
( 30.000 , 20.000)
( 20.000 , 10.000)

->v1 = v.window(1,2)

->print v1

Vec of 2D Point
...

list id :
0

Vector size
: 2

( 30.000 , 20.000)
( 20.000 , 10.000)

->

See also (class function)

window_x, window_xy

| HOME | BACK |


WINDOW_X

| HOME | BACK |

Purpose

To extract indices that fall within a window range, specified by the starting and ending x coordinates.

This is a one dimensional search.

Class

VecPt2D

Usage

{VecPt2D} ret  =  object.WINDOW_X({double} argm1,{double} argm2)

argm1 = start x coordinate of the window

argm2 = end x coordinate of the window

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)

->v1 = v.window_x(20,30)

->print v1

Vec of 2D Point
...

list id :
0

Vector size
: 2

( 20.000 , 30.000)
( 30.000 , 40.000)

->

See also (class function)

window, window_xy

| HOME | BACK |


WINDOW_XY

| HOME | BACK |

Purpose

To extract indices that fall within a window, specified by x y coordinates of the lower left and upper right of the window.

This is a two dimensional search.

Class

VecPt2D

Usage

{VecPt2D} ret  =  object.WINDOW_XY({double} argm1,{double} argm2,{double} argm3,{double} argm4)

argm1 = x coordinate of the lower left corner of window

argm2 = y coordinate of the lower left corner of window

argm3 = x coordinate of the upper right corner of window

argm4 = y coordinate of the upper right corner of window

Example:

->print v

Vec of 2D Point
...

list id :
0

Vector size
: 3

( 10.000 , 20.000)
( 20.000 , 30.000)
( 30.000 , 40.000)

->v1 = v.window_xy(0,20,10,30)

->print v1

Vec of 2D Point
...

list id :
0

Vector size
: 1

( 10.000 , 20.000)

->

See also (class function)

window, window_x

| HOME | BACK |