Пример #1
0
uint8_t DataMap::add_map(char *source_name, char* target_name, char* scale_string) {
  int8_t source_index = get_source_index(source_name);
  int8_t target_index = get_target_index(target_name);
  int8_t scale_power = get_scale_power(scale_string);
  if(source_index < 0 || target_index < 0) {
    return 0;
  } else {
    source_for_target[target_index] = source_index;
    EEPROM.write(EEPROM_ADDR_MAP_BEGIN + target_index*2, source_index);  
    scale_for_target[target_index] = powf(10.0, scale_power); 
    EEPROM.write(EEPROM_ADDR_MAP_BEGIN + target_index*2 + 1, scale_power);
    return 1;
  }
}
Пример #2
0
/*=============================================================================
  Function Name : get_cell_index
  Description   : Calculates index for accessing one-dimensional target arrays
                  from a float-value point in space, if in the target region.

  Inputs  : float x, float y, float z
  Outputs : int cell_i

  Notes : no.
=============================================================================*/
int get_cell_index (double x, double y, double z, int *cell_i) {
    int ix, iy, iz;

    if (x >= 0.0 && x < target_size_x && y >= 0.0 && y < target_size_y && z >= 0.0 &&
        z < target_size_z) {
        ix = x / cell_size_x;
        iy = y / cell_size_y;
        iz = z / cell_size_z;

        *cell_i = get_target_index (ix, iy, iz);  /* Determine initial cell */
        return 1;
    }
    else {
        return 0;
    }
}
 /**
  * Given an index in the columns array, figure out the edge that is 
  * the exact reverse of this edge --- ONLY WORKS FOR SYMMETRIC GRAPHS!
  * @param[in] target_index Index of the target that we want to reverse.
  * @return The reverse edge index if it exits.
  */
 int get_reverse_target_index (const int& target_index) const {
   VertexPairType edge_pair = get_edge (target_index);
   return get_target_index (edge_pair.second, edge_pair.first);
 }
Пример #4
0
 /**
  * Get the value at which this current edge is found. SORTING COMPULSORY.
  */
 double get_weight (int source, int target) const {
   const int index = get_target_index(source,target);
   return (0>index) ? 0.0 : weights [index];
 }