LEGO Engineering

Knowledgebase Home | Glossary | Favorites | Contact | Login Knowledgebase Home | Glossary | Favorites | Contact | Login
Search the Knowledgebase Browse by Category
Is it possible to use trigonometric functions (ie sin cos tan and so on) with ROBOLAB 2.9?
Article Details

Last Updated
19th of April, 2010

User Opinions (0 votes)
No users have voted.

How would you rate this answer?
Helpful
Not helpful
Yes, it is definitely possible to use sin, cos, tan, and many other functions in ROBOLAB 2.9 with the RCX.

Use the 'Evaluate Expression' block, found in the 'Container' menu in ROBOLAB 2.9. The 'Evaluate Expression' icon allows you to evaluate formulas, declare floating point variables, and perform floating point math. Just input your function (for example, sin(x) ) and the block will do the math for you.

The following can be used with this block, including trig and inverse trig as described below:

Possible operands are:
addition: +  
subtraction: -
multiplication: *
division: /
modulus: %         [eg. 3 % 2 = 1]
bitwise AND: &   [eg. 7 & 5 = 5]
bitwise OR: |       [eg. 5 | 2 = 7 ]

variable type: int, long, float    [eg. float test]
Parentheses: ()   [eg. 5+(red*2)/abs(sqrt(yellow/5.0))]
                                     ... note the 5.0 will make sure all math is done with floating point

Possible functions are:
trigonometric (all in radians): sin, cos, asin, acos, atan   [eg. sin (1.57)=1]
standard: abs, sqrt, sgn      [eg. sgn(-2) = -1]
logarithmic: ln10, ln, exp

Predefined variables:
containers: red, blue, yellow, c1, c2, c3,..,c48 (or C1..C32)
loop count down iterators: Loop_i, Loop_j, Loop_k (counts from n-1 to 0)
Motor Encoders: e1, e2, e3 (correspond to Motor A, B, C)
random number: r  [eg. r8 gives you a random number between 0 and 8 .. max value is 255]
sensors: s1, s2, s3, s4 (or S1,..S4 or Sensor1..Sensor4)
raw sensor value: SensorRaw1..SensorRaw4
100 msec Timers: T1, T2, T3, T4 (or Timer100ms1..Timer100ms4, or t1..t4))
10msec Timers: Timer10ms1..Timer10ms4
1msec Timers: Timer1ms1... Timer1ms4
System Time (Time since on): SystemTime
Current motor state: MotorStatus1..MotorStatus3 (0=idle, 1=hold, 16=Ramp Up, 32=Running, 64=Ramp Down)
mail (RCX only): m
clock (RCX only): w





kw
Visitor Comments
No visitor comments posted. Post a comment
Post Comment for "Is it possible to use trigonometric functions (ie sin cos tan and so on) with ROBOLAB 2.9?"
To post a comment for this article, simply complete the form below. Fields marked with an asterisk are required.
   Your Name:
   Email Address:
* Your Comment:
* Enter the code below:
 
Related Articles
Attachments
No attachments were found.

Home | About Us | Contact Us

© 2010 Center for Engineering Educational Outreach, Tufts University
© 2010 The LEGO Group. All rights reserved.