Difference between revisions of "Kray3 SDK/Arithmetic operations"

From Kray
Jump to: navigation, search
(Arithmetic operations)
(changed code template)
Line 6: Line 6:
 
== Add ==
 
== Add ==
 
You can perform '''ADD''' operation on doubles, strings and vectors.
 
You can perform '''ADD''' operation on doubles, strings and vectors.
 
+
{{Kray3script | path=operators/operators1.kray | runbutton=1}}
<include highlight="kray3" src="http://www.kraytracing.com/pub/kray3_script/operators/operators1.kray" />{{Runkray3live|path=operators/operators1.kray}}
+
  
 
== Subtract ==
 
== Subtract ==
 
You can perform '''SUBTRACT''' operation on doubles and vectors.
 
You can perform '''SUBTRACT''' operation on doubles and vectors.
 
+
{{Kray3script | path=operators/operators2.kray | runbutton=1}}
<include highlight="kray3" src="http://www.kraytracing.com/pub/kray3_script/operators/operators2.kray" />{{Runkray3live|path=operators/operators2.kray}}
+
  
 
== Unary - ==
 
== Unary - ==
 
Unary operations can also be performed on doubles and vectors.
 
Unary operations can also be performed on doubles and vectors.
 
+
{{Kray3script | path=operators/operators3.kray | runbutton=1}}
<include highlight="kray3" src="http://www.kraytracing.com/pub/kray3_script/operators/operators3.kray" />{{Runkray3live|path=operators/operators3.kray}}
+
  
 
== Multiplication ==
 
== Multiplication ==
 
Can be performed on double, axes*axes, vector*axes, vector*vector.
 
Can be performed on double, axes*axes, vector*axes, vector*vector.
 
+
{{Kray3script | path=operators/operators4.kray | runbutton=1}}
<include highlight="kray3" src="http://www.kraytracing.com/pub/kray3_script/operators/operators4.kray" />{{Runkray3live|path=operators/operators4.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.
 
+
{{Kray3script | path=operators/operators5.kray | runbutton=1}}
<include highlight="kray3" src="http://www.kraytracing.com/pub/kray3_script/operators/operators5.kray" />{{Runkray3live|path=operators/operators5.kray}}
+
  
 
== Modulo ==
 
== Modulo ==
 
Modulo (%) can be performed on doubles.
 
Modulo (%) can be performed on doubles.
 
+
{{Kray3script | path=operators/operators6.kray | runbutton=1}}
<include highlight="kray3" src="http://www.kraytracing.com/pub/kray3_script/operators/operators6.kray" />{{Runkray3live|path=operators/operators6.kray}}
+
  
 
== Power ==
 
== Power ==
 
^ to the power of operator works on doubles.
 
^ to the power of operator works on doubles.
<include highlight="kray3" src="http://www.kraytracing.com/pub/kray3_script/operators/operators7.kray" />{{Runkray3live|path=operators/operators7.kray}}
+
{{Kray3script | path=operators/operators7.kray | runbutton=1}}
 
   
 
   
 
== Comparision ==
 
== Comparision ==
 
You can use comparision operators < > <= >= on doubles, strings.
 
You can use comparision operators < > <= >= on doubles, strings.
 
+
{{Kray3script | path=operators/operators8.kray | runbutton=1}}
<include highlight="kray3" src="http://www.kraytracing.com/pub/kray3_script/operators/operators8.kray" />{{Runkray3live|path=operators/operators8.kray}}
+
 
   
 
   
 
You can use comparision operators == != on doubles, strings, vectors and axes.
 
You can use comparision operators == != on doubles, strings, vectors and axes.
+
{{Kray3script | path=operators/operators9.kray | runbutton=1}}
<include highlight="kray3" src="http://www.kraytracing.com/pub/kray3_script/operators/operators9.kray" />{{Runkray3live|path=operators/operators9.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.
 
+
{{Kray3script | path=operators/operators10.kray | runbutton=1}}
<include highlight="kray3" src="http://www.kraytracing.com/pub/kray3_script/operators/operators10.kray" />{{Runkray3live|path=operators/operators10.kray}}
+
  
 
== Concatenation ==
 
== Concatenation ==
 
Concatenation operators work on doubles, vectors, strings.
 
Concatenation operators work on doubles, vectors, strings.
<include highlight="kray3" src="http://www.kraytracing.com/pub/kray3_script/operators/operators11.kray" />{{Runkray3live|path=operators/operators11.kray}}
+
{{Kray3script | path=operators/operators11.kray | runbutton=1}}
  
 
== Convert vector>axis ==
 
== Convert vector>axis ==
 
<> converts vector to axis.
 
<> converts vector to axis.
 
+
{{Kray3script | path=operators/operators12.kray | runbutton=1}}
Concatenation operators work on doubles, vectors, strings.
+
<include highlight="kray3" src="http://www.kraytracing.com/pub/kray3_script/operators/operators12.kray" />{{Runkray3live|path=operators/operators12.kray}}
+
  
 
== Exponential operator ==
 
== Exponential operator ==
Line 66: Line 55:
  
 
Concatenation operators work on doubles, vectors, strings.
 
Concatenation operators work on doubles, vectors, strings.
<include highlight="kray3" src="http://www.kraytracing.com/pub/kray3_script/operators/operators13.kray" />{{Runkray3live|path=operators/operators13.kray}}
+
{{Kray3script | path=operators/operators13.kray | runbutton=1}}

Revision as of 14:08, 16 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" src="/pub/kray3_script/operators/operators1.kray"></include>{{#ifeq: 1|1|

Run in KrayLive|}}

Subtract

You can perform SUBTRACT operation on doubles and vectors.

<include highlight="kray3" src="/pub/kray3_script/operators/operators2.kray"></include>{{#ifeq: 1|1|

Run in KrayLive|}}

Unary -

Unary operations can also be performed on doubles and vectors.

<include highlight="kray3" src="/pub/kray3_script/operators/operators3.kray"></include>{{#ifeq: 1|1|

Run in KrayLive|}}

Multiplication

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

<include highlight="kray3" src="/pub/kray3_script/operators/operators4.kray"></include>{{#ifeq: 1|1|

Run in KrayLive|}}

Division

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

<include highlight="kray3" src="/pub/kray3_script/operators/operators5.kray"></include>{{#ifeq: 1|1|

Run in KrayLive|}}

Modulo

Modulo (%) can be performed on doubles.

<include highlight="kray3" src="/pub/kray3_script/operators/operators6.kray"></include>{{#ifeq: 1|1|

Run in KrayLive|}}

Power

^ to the power of operator works on doubles.

<include highlight="kray3" src="/pub/kray3_script/operators/operators7.kray"></include>{{#ifeq: 1|1|

Run in KrayLive|}}

Comparision

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

<include highlight="kray3" src="/pub/kray3_script/operators/operators8.kray"></include>{{#ifeq: 1|1|

Run in KrayLive|}}

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

<include highlight="kray3" src="/pub/kray3_script/operators/operators9.kray"></include>{{#ifeq: 1|1|

Run in KrayLive|}}

Logic operators

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

<include highlight="kray3" src="/pub/kray3_script/operators/operators10.kray"></include>{{#ifeq: 1|1|

Run in KrayLive|}}

Concatenation

Concatenation operators work on doubles, vectors, strings.

<include highlight="kray3" src="/pub/kray3_script/operators/operators11.kray"></include>{{#ifeq: 1|1|

Run in KrayLive|}}

Convert vector>axis

<> converts vector to axis.

<include highlight="kray3" src="/pub/kray3_script/operators/operators12.kray"></include>{{#ifeq: 1|1|

Run in KrayLive|}}

Exponential operator

E - exponential operator.

Concatenation operators work on doubles, vectors, strings.

<include highlight="kray3" src="/pub/kray3_script/operators/operators13.kray"></include>{{#ifeq: 1|1|

Run in KrayLive|}}