Skip to content

[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McGeDoubleArray

Class: McGeDoubleArray ​

2d.McGeDoubleArray

McGeDoubleArray represents an array container of double precision floating-point numbers.

Description

This class is used to store and process floating-point sets, commonly used in numerical sampling, coordinate value caching Transform parameters and other scenarios that require continuous floating-point data.

Example

ts
import { McGeDoubleArray } from "mxcad";

const values = new McGeDoubleArray();
values.append(1.2);
values.append(3.4);
values.append(5.6);

console.log(values.at(1)); //Obtain the value of the first index position;
console.log(values.length()); //Obtain the length of the array;

Table of contents ​

Constructors ​

Properties ​

Methods ​

Constructors ​

constructor ​

• new McGeDoubleArray(imp?, isDestroyImp?)

Constructor.

Parameters ​

NameTypeDescription
imp?` ObjectInternal implementation object
isDestroyImp?boolean-

Properties ​

imp ​

• imp: any

Internal implementation object

Methods ​

append ​

▸ append(val): void

Add a value

Parameters ​

NameTypeDescription
ValnumberDouble precision floating-point number

Returns ​

void


at ​

▸ at(index): number

Retrieve the values of data elements through array indexing

Parameters ​

NameTypeDescription
Indexnumberarray index

Returns ​

number


clear ​

▸ clear(): void

Clear the array

Returns ​

void


copy ​

▸ copy(val): McGeDoubleArray

Copy the value of the object

Parameters ​

NameTypeDescription
Val[McGeDoubleArray] (2d. McGeDoubleArray. md)Double precision floating-point array

Returns ​

McGeDoubleArray

Example

ts
import { McGeDoubleArray } from "mxcad"

//Array1 represents a double precision floating-point array
 const array2 = new McGeDoubleArray();
 array2.copy(array1);

//Now array2 and array1 have the same value

forEach ​

▸ forEach(call): void

Traverse the array

Parameters ​

NameTypeDescription
Call(val: number, index: number)=>voidcallback function

Returns ​

void

Example

ts
import { McGeDoubleArray } from "mxcad"

  const array = new McGeDoubleArray();
  array.append(3.14159);
  array.forEach((val,index)=>{
    console.log(`Value at index ${index}: ${value}`);
  })

length ​

▸ length(): number

Return the length of the array

Returns ​

number

Array length


setAt ​

▸ setAt(index, val): void

Set the value of data elements through array indexing

Parameters ​

NameTypeDescription
indexnumber-
ValnumberDouble precision floating-point number

Returns ​

void

Example

ts
import { McGeDoubleArray } from "mxcad"

  const array = new McGeDoubleArray();
array.setAt(1, 3.14159); //  Set the value of the position with index 1 to 3.14159