Difference between revisions of "Kray3 SDK/Arithmetic operations"

From Kray
Jump to: navigation, search
m (Add)
m
Line 11: Line 11:
 
You can perform '''SUBTRACT''' operation on doubles and vectors.
 
You can perform '''SUBTRACT''' operation on doubles and vectors.
  
<include highlight="kray3" lines="11-14" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />
+
<include highlight="kray3" lines="11-14" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />{{Runkray3live|path=operators.kray}}
{{Runkray3live|path=operators.kray}}
+
  
 
=== Unary - ===
 
=== Unary - ===
 
Unary operations can also be performed on doubles and vectors.
 
Unary operations can also be performed on doubles and vectors.
  
<include highlight="kray3" lines="16-18" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />
+
<include highlight="kray3" lines="16-18" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />{{Runkray3live|path=operators.kray}}
{{Runkray3live|path=operators.kray}}
+
  
 
== Division==
 
== Division==
 
Can be performed on double, axes/axes, vector/axes, vector/vector.
 
Can be performed on double, axes/axes, vector/axes, vector/vector.
  
<include highlight="kray3" lines="27-34" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />
+
<include highlight="kray3" lines="27-34" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />{{Runkray3live|path=operators.kray}}
{{Runkray3live|path=operators.kray}}
+
  
 
== Modulo ==
 
== Modulo ==
 
Modulo (%) can be performed on doubles.
 
Modulo (%) can be performed on doubles.
  
<include highlight="kray3" lines="36-37" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />
+
<include highlight="kray3" lines="36-37" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />{{Runkray3live|path=operators.kray}}
{{Runkray3live|path=operators.kray}}
+
  
 
== Power ==
 
== Power ==
 
^ to the power of operator works on doubles.
 
^ to the power of operator works on doubles.
<include highlight="kray3" lines="39-40" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />
+
<include highlight="kray3" lines="39-40" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />{{Runkray3live|path=operators.kray}}
{{Runkray3live|path=operators.kray}}
+
 
   
 
   
 
== Comparision ==
 
== Comparision ==
 
You can use comparision operators < > <= >= on doubles, strings.
 
You can use comparision operators < > <= >= on doubles, strings.
 
    
 
    
<include highlight="kray3" lines="43-47" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />
+
<include highlight="kray3" lines="43-47" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />{{Runkray3live|path=operators.kray}}
{{Runkray3live|path=operators.kray}}
+
 
   
 
   
 
You can use comparision operators == != on doubles, strings, vectors and axes.
 
You can use comparision operators == != on doubles, strings, vectors and axes.
 
   
 
   
<include highlight="kray3" lines="49-56" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />
+
<include highlight="kray3" lines="49-56" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />{{Runkray3live|path=operators.kray}}
{{Runkray3live|path=operators.kray}}
+
 
   
 
   
 
== Logic operators ==
 
== Logic operators ==
 
And (&) Or (|), Not (!) logic operators can be used on doubles.
 
And (&) Or (|), Not (!) logic operators can be used on doubles.
  
<include highlight="kray3" lines="59-64" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />
+
<include highlight="kray3" lines="59-64" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />{{Runkray3live|path=operators.kray}}
{{Runkray3live|path=operators.kray}}
+
  
 
== Concatenation ==
 
== Concatenation ==
 
Concatenation operators work on doubles, vectors, strings.
 
Concatenation operators work on doubles, vectors, strings.
<include highlight="kray3" lines="67-70" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />
+
<include highlight="kray3" lines="67-70" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />{{Runkray3live|path=operators.kray}}
{{Runkray3live|path=operators.kray}}
+
  
 
== Convert vector>axis ==
 
== Convert vector>axis ==
Line 63: Line 54:
  
 
Concatenation operators work on doubles, vectors, strings.
 
Concatenation operators work on doubles, vectors, strings.
<include highlight="kray3" lines="73-74" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />
+
<include highlight="kray3" lines="73-74" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />{{Runkray3live|path=operators.kray}}
{{Runkray3live|path=operators.kray}}
+
  
 
== Exponential operator ==
 
== Exponential operator ==
Line 70: Line 60:
  
 
Concatenation operators work on doubles, vectors, strings.
 
Concatenation operators work on doubles, vectors, strings.
<include highlight="kray3" lines="77-80" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />
+
<include highlight="kray3" lines="77-80" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />{{Runkray3live|path=operators.kray}}
{{Runkray3live|path=operators.kray}}
+

Revision as of 14:40, 13 August 2012

Arithmetic operations

Several standard arithmetic operations can be used inside Kray script.

Add

You can perform ADD operation on doubles, strings and vectors.

<include highlight="kray3" lines="3-9" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />

Run in KrayLive

Subtract

You can perform SUBTRACT operation on doubles and vectors.

<include highlight="kray3" lines="11-14" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />

Run in KrayLive

Unary -

Unary operations can also be performed on doubles and vectors.

<include highlight="kray3" lines="16-18" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />

Run in KrayLive

Division

Can be performed on double, axes/axes, vector/axes, vector/vector.

<include highlight="kray3" lines="27-34" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />

Run in KrayLive

Modulo

Modulo (%) can be performed on doubles.

<include highlight="kray3" lines="36-37" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />

Run in KrayLive

Power

^ to the power of operator works on doubles. <include highlight="kray3" lines="39-40" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />

Run in KrayLive

Comparision

You can use comparision operators < > <= >= on doubles, strings.

<include highlight="kray3" lines="43-47" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />

Run in KrayLive

You can use comparision operators == != on doubles, strings, vectors and axes.

<include highlight="kray3" lines="49-56" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />

Run in KrayLive

Logic operators

And (&) Or (|), Not (!) logic operators can be used on doubles.

<include highlight="kray3" lines="59-64" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />

Run in KrayLive

Concatenation

Concatenation operators work on doubles, vectors, strings. <include highlight="kray3" lines="67-70" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />

Run in KrayLive

Convert vector>axis

<> converts vector to axis.

Concatenation operators work on doubles, vectors, strings. <include highlight="kray3" lines="73-74" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />

Run in KrayLive

Exponential operator

E - exponential operator.

Concatenation operators work on doubles, vectors, strings. <include highlight="kray3" lines="77-80" src="http://www.kraytracing.com/pub/kray3_script/operators.kray" />

Run in KrayLive