πŸ“– PEPS Quick Reference

Essential Syntax Rules & Common Pitfalls

⚠️ Critical Syntax Rules

These are the most common issues encountered during PEPS/OPTICAM development. Memorize these!

Topic βœ… Correct ❌ Wrong
Square Root w_result = (w_value) @ 0.5 sqrt(w_value)
Modulus w_result = w_a % w_b mod(w_a, w_b)
Trig Functions w_angle = acs(w_dot)
(returns degrees)
w_angle = acos(w_dot) * 180 / pi
Negative in SLD w_neg = 0 - w_val
sld transform 1 i_body w_neg 0 0 0 0 0
sld transform 1 i_body -w_val 0 0 0 0 0
Expressions in SLD w_temp = w_a + w_b
sld rotate 1 i_body 0 0 0 0 0 1 w_temp
sld rotate 1 i_body 0 0 0 0 0 1 (w_a + w_b)
File Line Endings CRLF (Windows) LF only (Unix)
⚠️ Important: PEPS does not have sqrt(), mod(), or acos() functions. Using them will cause silent failures or errors.

πŸ”’ Math Operations

Power Operator (@)

'*** The @ operator raises to a power
w_squared = w_value @ 2        '*** valueΒ²
w_cubed = w_value @ 3          '*** valueΒ³
w_sqrt = w_value @ 0.5         '*** √value (square root)
w_cubeRoot = w_value @ 0.333   '*** βˆ›value (cube root)

Available Operators

Operator Purpose Example
+ Addition w_sum = w_a + w_b
- Subtraction w_diff = w_a - w_b
* Multiplication w_prod = w_a * w_b
/ Division w_quot = w_a / w_b
@ Power w_pow = w_a @ w_b
% Modulus w_mod = w_a % w_b

Logical Operators

'*** Boolean/logical operators (lowercase)
if ( i_a = 1 ) and ( i_b = 2 ) then ...
if ( i_a = 1 ) or ( i_b = 2 ) then ...
if not ( i_flag ) then ...
if ( i_a ) xor ( i_b ) then ...

πŸ“ Trigonometry

Remember: All PEPS trig functions use DEGREES, not radians!
Function Purpose Example
sin(angle) Sine w_s = sin(45) β†’ 0.707
cos(angle) Cosine w_c = cos(45) β†’ 0.707
tan(angle) Tangent w_t = tan(45) β†’ 1.0
asn(value) Arc sine (returns degrees) w_a = asn(0.5) β†’ 30
acs(value) Arc cosine (returns degrees) w_a = acs(0.5) β†’ 60
atn(value) Arc tangent (returns degrees) w_a = atn(1) β†’ 45
'*** Example: Calculate angle from dot product
w_dot = w_nx1 * w_nx2 + w_ny1 * w_ny2 + w_nz1 * w_nz2
w_angleDeg = acs(w_dot)    '*** Returns DEGREES, no conversion needed!

🧊 Solid (SLD) Commands

Transform Commands

'*** ROTATE around axis defined by two points
sld rotate <copies> <body> <x1> <y1> <z1> <x2> <y2> <z2> <angle_deg>

'*** TRANSLATE (move)
sld transform <copies> <body> <dx> <dy> <dz> 0 0 0

'*** TRANSFORM with matrix
sld body transform <body> m(<matrix_num>)
⚠️ Critical: SLD commands cannot accept expressions or negative values directly!
'*** WRONG:
sld transform 1 i_body (w_x + 5) 0 0 0 0 0
sld transform 1 i_body -w_x 0 0 0 0 0

'*** CORRECT:
w_temp = w_x + 5
sld transform 1 i_body w_temp 0 0 0 0 0

w_neg = 0 - w_x
sld transform 1 i_body w_neg 0 0 0 0 0

Boolean Operations

sld unite <target> <count> <tool>       '*** Union
sld subtract <target> <count> <tool>    '*** Subtraction
sld intersect <target> <count> <tool>   '*** Intersection

SLD INT Quirk

Note: For SLD INT (intersect), the target must appear in BOTH the count AND the body list:
'*** Intersect target with one tool:
SLD INT i_target 2 i_target i_tool   '*** Count=2, list includes target!

Entity Conversion

'*** SLD CNV ENT types:
'***   0 = line/arc
'***   6 = face
'***   7 = wire
'***   8 = wire (output)

'*** Face to kurve (via wire):
sld cnv ent 6 0 0 -i_face    '*** Face β†’ edges

'*** Line/arc to wire:
sld cnv ent 0 8 0            '*** Geometry β†’ wire body

πŸ”„ Kurve Operations

Kurve Transforms Use MATRIX

'*** Kurves cannot be rotated directly - use matrix operations

'*** WRONG (does not exist):
rotate k(5) 45

'*** CORRECT:
set m1
rotate m1 z 45                '*** Rotate matrix 45Β° around Z
translate m1 x10 y20 z0       '*** Add translation
copy k(5) m1                  '*** Apply matrix to kurve
delete m1                     '*** Clean up matrix

Getting Kurve Data

'*** Get kurve statistics
get k(n) d i_spans w_perimeter w_area

'*** Get span data
get k(n) i_spanNum i_type w_xs w_ys w_xe w_ye w_xc w_yc

'*** Span types:
'***   0 = line
'***   1 = CCW arc
'***  -1 = CW arc
'*** -99 = end of kurve

πŸ“Š VDM (Virtual Data Management)

Basic VDM Operations

'*** Allocate temporary VDM
call allocVDM
i_mySet = i_return

'*** Open/create
vdm exist i_set i_mySet
if i_set = 0 then
   vdm create i_set i_mySet 0
else
   vdm open i_set i_mySet 0
end if

'*** Read/write
vdm write i_set w_value 1
vdm read i_set w_value i_ret

'*** Close and free
vdm close i_set
call freeVDM i_mySet
Tip: VDM size variable must be w_ (float) type, not i_ (integer).
local w_size    '*** CORRECT
vdm size i_set w_size

πŸ“ File Requirements

.ovm Files (Macros)

  • Must use CRLF line endings
  • Use global for inline global declarations
  • Comments: '*** comment or ;'*** inline

.var Files (Variables)

  • Must use CRLF line endings
  • No global keyword needed
  • Variables are inherently global
Line Endings: If PEPS gives syntax errors on files that look correct, check line endings. Use Notepad++ β†’ Edit β†’ EOL Conversion β†’ Windows (CRLF).

🏷️ Entity Classes

Class Value Description
Plane4001Flat surface
Cylinder4002Cylindrical surface
Cone4003Conical surface
Sphere4004Spherical surface
Torus4005Toroidal surface