Page 3 of 3

Re: Trig functions in NXT-G

Posted: 02 Oct 2010, 17:30
by afanofosc
New blocks often are written to encapsulate a specific task, such as reading values from I2C sensors made by HiTechnic or Mindsensors.com. A number of custom blocks that you can install into the LEGO MINDSTORMS NXT software provide things like cos, sin, sqrt, etc... They don't call a new opcode or system call. They use existing opcodes and system calls to do multiple things that by wrapping in a convenient package can be easily reused. So the cos block mentioned earlier in this thread uses an algorithm to approximate the value of cosine for whatever input you wire into the block. If the firmware had a native cos opcode and the NXT-G compiler could dynamically generate the right output for new opcodes it would be possible to write an NXT-G block that just emitted something like "cos out, angle" which would write cos(angle) to the provided output variable.

John Hansen

Re: Trig functions in NXT-G

Posted: 03 Oct 2010, 08:42
by schodet
Writing NXT-G blocks is still a mystery for me. How is it done?

There should be a way to make a really ugly hack to give NXT-G more access to new firmware, one of the ugliest would be to use a specific I2C address to talk to the firmware, but I am sure (read: I hope) there is cleaner ways.