MCPcopy Create free account
hub / github.com/bdring/FluidNC / read_atan

Function read_atan

FluidNC/src/Expression.cpp:623–640  ·  view source on GitHub ↗

! \brief Reads a slash and the second argument to the ATAN function, starting at the index given by the pos offset. Then it computes the value of the ATAN operation applied to the two arguments. \param line pointer to RS274/NGC code (block). \param pos offset into line where expression starts. \param value pointer to float where result is to be stored. \returns #Error::Ok enum value if processed

Source from the content-addressed store, hash-verified

621\returns #Error::Ok enum value if processed without error, appropriate \ref Error enum value if not.
622*/
623static Error read_atan(const char* line, size_t& pos, float& value) {
624 float argument2;
625
626 if (line[pos] != '/')
627 return Error::ExpressionSyntaxError; // Slash missing after first ATAN argument
628
629 pos++;
630
631 if (line[pos] != '[')
632 return Error::ExpressionSyntaxError; // Left bracket missing after slash with ATAN;
633
634 Error status;
635
636 if ((status = expression(line, pos, argument2)) == Error::Ok)
637 value = atan2f(value, argument2) * DEGRAD; /* value in radians, convert to degrees */
638
639 return status;
640}
641
642/*! \brief Reads the value out of an unary operation of the line, starting at the
643index given by the pos offset. The ATAN operation is

Callers 1

read_unaryFunction · 0.85

Calls 1

expressionFunction · 0.85

Tested by

no test coverage detected