Microchip® Advanced Software Framework

physics.c File Reference

ASF Sensor API physics utilities.

This module defines types and operations that support basic physical modelling and equations for sensor data.

Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.

#include "physics.h"


#define degrees(a)   (RAD_TO_DEG * (a))


bool field_direction (vector3_t *field, scalar_t *theta, scalar_t *delta, scalar_t *strength)
 Calculate direction, inclination, and field strength. More...

#define degrees (   a)    (RAD_TO_DEG * (a))

Referenced by field_direction().

bool field_direction ( vector3_t field,
scalar_t theta,
scalar_t delta,
scalar_t strength 

Calculate direction, inclination, and field strength.

This routine calculates horizontal direction, vertical inclination and net field magnitude for a "raw" (unscaled) magnetic field sample from a 3-axis magnetometer.

fieldMagnetometer raw vector field sample input
thetaCalculated direction angle (degrees) output
deltaCalculated inclination angle (degrees) output
strengthCalculated raw vector field magnitude output
bool true if the call succeeds, else false is returned.

References degrees, vector3_magnitude(), vector3_scale(), vector3_t::x, vector3_t::y, and vector3_t::z.

Referenced by ak8975_get_heading(), and hmc5883l_get_heading().