JavaScript does not support call-by-reference type of function parameters for basic types. Correspondingly, Realsoft 3D methods returning data back to the caller through the method parameters won't work. To overcome this limitation Realsoft 3D implements r3Int object type.
r3Int - constructor for int
v = new r3Int()
value - inting point number
v - new int object
Creates a new int object. If you don't pass any parameters to the constructor, the value is initialized to zero.
v = new r3Int(10);
add - addition
v2 = v.add(v1);
v1 - int
v2 = result int
This adds the given int to the object in question and returns the result as a new integer. The operation doesn't change the value of the object.
v = new r3Int(0.1); r = v.add(0.1);
fadd - int addition
v.fadd(v2);
v2 - int to be added
-
Int operation v = v+v2.
v = new r3Int(1); v.fadd(0.1); // add 0.1 to the current value
set - set value
v.set(value);
value - inting point number
-
Set new value to the int
v = new r3Int(); v.set(10.3);
sub - int subtraction
v3 = v.sub(v2);
v2 - int to be subracted
int - the result of the subtraction
Returns a new int containing the result of int operation 'v - v2'.
v = new r3Int(10); v2 = v.sub(5); v2.print(); // 5
fsub - int subtraction
v.fsub(v2);
v2 - int to be subracted
-
Subtracts given int 'v2' from the int in question.
v = new r3Int(1); v.fsub(0.5); v.print(); // 0.5
neg - negate
v2 = v.neg();
-
v2 - int
Returns negative value of the object.
v = new r3Int(1); v2 = v.neg();
fneg - negative
v.neg();
-
-
Makes the int negative integer.
v = new r3Int(1); v.fneg(); v.print(); // -1
mul - multiplication
v2 = v.mul(f);
f - int number
v2 - result
Multiplies the int with the given value and returns the value.
v = new r3Int(2); v2 = v.mul(10); v2.print(); // 20
fmul - multiplication
v.fmul(f);
f - inting point number
-
Multiplies the int by given value
v = new r3Int(2); v.fmul(10); // new value == 20
div - division by scalar
v2 = v.div(f);
f - inting point number
v2 - int
Divides the int by given value and returns a new int holding the result.
v = new r3Int(10); v2 = v.div(2); v2.print(); // 5
fdiv - division by scalar
v.fdiv(f);
f - inting point number
-
Divides the int by given value.
v = new r3Int(1); v.fdiv(2); // 0.5
cmul
v3 = v.cmul(v2);
v2 - int
v3 - int
Component wise multiplication. Multiplies each component in 'v' by corresponding component of 'v2' and returns the result as a new integer.
v = new r3Vect(1, 2, 3);
cmp - compare
b = v.cmp(v2, tolerance);
v2 - int
tolerance - tolerance
b - boolean, true if ints are identical within the given tolerance
Compare the given int 'v2' agains the int in question and return true if the ints are within the given tolerance. Otherwise returns false.
v = new r3Vect(1.1);
if(v.cmp(1.2, 0.01)) {
print("Not identical");
} else {
print("Identical");
}
print - print int
v.print()
-
-
Print out the current value of the integer.
v.set(1.5); v.print();