Variables

Enlarge the font size of the script editor: Ctrl+Shift+>  .

Variables

int $rad=2;

sphere -radius $rad;

Number types for variables: int, float, string, vector, and matrix.

1. For string, concatenate is done by "+"; the number of characters in the string is calculated from size(string).

2. Vector variables allow you to store three floating-point values. Typically, used to store positions and directions.

sphere;

vector $p=<<10.0, 5.0, 2.5>>;

move -absolute ($p.x) ($p.y) ($p.z);

3. To access the vector component they must be enclosed in parentheses.

4. You cannot directly assign a number to a vector's component. To change x component of $p,

$p=<<3.0, $p.y, $p.z>>;

print $p;

//Result: 3.0 5.0 2.5

5. Array type: the indices are base 0. The total number of elements in the array can be got from size function. Also you can add new element directly to the array, no matter exceeding the initial size. To remove the array and free the memory, use clear function. However, no direct way to remove elements one by one from a array.

6. Array is only one-dimension, cannot be two dimensions or higher.

7. Matrix is two dimension, cannot be resized after initialised. Both the two dimensions' index must be explicitly declared.

matrix $m[2][4] = << 3 , 4 , 6 , 7 " 3 , 9 , 0 , 1 >>;

p r i n t ( $m[O][O] )" / / Result. 3

p r i n t ( $m[1][3] )" / / Result. 1

8. You can access the element outside of the initial range for array, but cannot for matrix.

9. Once a variable's type is set, either explicitly or implicitly, it cannot be changed.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值