示例#1
0
文件: vector3d.hpp 项目: barthess/u
void vector3d_normalize(T* v){
  T R;
  R = vector3d_modulus(v);
  v[0] /= R;
  v[1] /= R;
  v[2] /= R;
}
示例#2
0
//convert vector to a vector with same direction and modulus 1
void vector3d_normalize(float* vector){
  float R;
  R = vector3d_modulus(vector);
  vector[0] /= R;
  vector[1] /= R;
  vector[2] /= R;
}
示例#3
0
文件: mma8451.cpp 项目: barthess/u
void MMA8451::update_stillness(const float *result){
  float cross[3];
  float filtered[3];
  float modulus_cross;
  float modulus_delta;
  uint32_t i = 0;

  /* update array of filters */
  for (i=0; i<3; i++)
    filtered[i] = abeta[i].update(result[i], *still_flen);

  /* calculate differences between vectors */
  vector3d_cross(result, filtered, cross);
  modulus_cross = vector3d_modulus(cross);
  modulus_delta = vector3d_modulus(result) - vector3d_modulus(filtered);

  if ((fabsf(modulus_delta) > *still_thr) || (fabsf(modulus_cross) > *still_thr))
    immobile = false;
}