03.08.2013 Views

Embedded Software and Motor Control Libraries for PXR40xx

Embedded Software and Motor Control Libraries for PXR40xx

Embedded Software and Motor Control Libraries for PXR40xx

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.34.2 Arguments<br />

Table 4-44. GFLIB_AtanYX_F32 arguments<br />

Type Name Direction Description<br />

tFrac32 f32InY input The ordinate of the input vector (y coordinate).<br />

tFrac32 f32InX input The abscissa of the input vector (x coordinate).<br />

4.34.3 Return<br />

The function returns the angle between the positive x-axis of a plane <strong>and</strong> the direction of<br />

the vector given by the x <strong>and</strong> y coordinates provided as parameters.<br />

4.34.4 Description<br />

The function returns the angle between the positive x-axis of a plane <strong>and</strong> the direction of<br />

the vector given by the x <strong>and</strong> y coordinates provided as parameters. The first parameter,<br />

f32InY, is the ordinate (the y coordinate) <strong>and</strong> the second one, f32InX, is the abscissa (the<br />

x coordinate).<br />

Both the input parameters are assumed to be in the fractional range of [-1, 1). The<br />

computed angle is limited by the fractional range of [-1, 1), which corresponds to the real<br />

range of [- π, π). The counter-clockwise direction is assumed to be positive <strong>and</strong> thus a<br />

positive angle will be computed if the provided ordinate (f32InY) is positive. Similarly, a<br />

negative angle will be computed <strong>for</strong> the negative ordinate.<br />

The calculations are per<strong>for</strong>med in a few steps.<br />

Chapter 4 API References<br />

In the first step, the angle is positioned within the correct half-quarter of the<br />

circumference of a circle by dividing the angle into two parts: the integral multiple of 45<br />

deg (half-quarter) <strong>and</strong> the remaining offset within the 45 deg range. Simple geometric<br />

properties of the Cartesian coordinate system are used to calculate the coordinates of the<br />

vector with the calculated angle offset.<br />

In the second step, the vector ordinate is divided by the vector abscissa (y/x) to obtain the<br />

tangent value of the angle offset. The angle offset is computed by applying the ordinary<br />

arctangent function.<br />

The sum of the integral multiple of half-quarters <strong>and</strong> the angle offset within a single halfquarter<br />

<strong>for</strong>m the angle to be computed. The function will return 0 if both input arguments<br />

are 0.<br />

<strong>Embedded</strong> <strong>Software</strong> <strong>and</strong> <strong>Motor</strong> <strong>Control</strong> <strong>Libraries</strong> <strong>for</strong> <strong>PXR40xx</strong>, Rev. 1.0<br />

Freescale Semiconductor, Inc. 247

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!