* - http://tizen.org/feature/sensor.rotation_vector\n
* - http://tizen.org/feature/sensor.gravity\n
* - http://tizen.org/feature/sensor.heart_rate_monitor\n
- * - http://tizen.org/feature/sensor.hrm_led_green\n
- * - http://tizen.org/feature/sensor.hrm_led_ir\n
- * - http://tizen.org/feature/sensor.hrm_led_red\n
+ * - http://tizen.org/feature/sensor.heart_rate_monitor.led_green\n
+ * - http://tizen.org/feature/sensor.heart_rate_monitor.led_ir\n
+ * - http://tizen.org/feature/sensor.heart_rate_monitor.led_red\n
+ * - http://tizen.org/feature/sensor.gyroscope.uncalibrated\n
+ * - http://tizen.org/feature/sensor.magnetometer.uncalibrated\n
+ * - http://tizen.org/feature/sensor.gyroscope_rotation_vector\n
+ * - http://tizen.org/feature/sensor.geomagnetic_rotation_vector\n
*
* It is recommended to design feature related codes in your application for reliability.\n
*
* - http://tizen.org/feature/sensor.rotation_vector\n
* - http://tizen.org/feature/sensor.gravity\n
* - http://tizen.org/feature/sensor.heart_rate_monitor\n
- * - http://tizen.org/feature/sensor.hrm_led_green\n
- * - http://tizen.org/feature/sensor.hrm_led_ir\n
- * - http://tizen.org/feature/sensor.hrm_led_red\n
+ * - http://tizen.org/feature/sensor.heart_rate_monitor.led_green\n
+ * - http://tizen.org/feature/sensor.heart_rate_monitor.led_ir\n
+ * - http://tizen.org/feature/sensor.heart_rate_monitor.led_red\n
+ * - http://tizen.org/feature/sensor.gyroscope.uncalibrated\n
+ * - http://tizen.org/feature/sensor.magnetometer.uncalibrated\n
+ * - http://tizen.org/feature/sensor.gyroscope_rotation_vector\n
+ * - http://tizen.org/feature/sensor.geomagnetic_rotation_vector\n
*
* It is recommended to design feature related codes in your application for reliability.\n
*
* - http://tizen.org/feature/sensor.rotation_vector\n
* - http://tizen.org/feature/sensor.gravity\n
* - http://tizen.org/feature/sensor.heart_rate_monitor\n
- * - http://tizen.org/feature/sensor.hrm_led_green\n
- * - http://tizen.org/feature/sensor.hrm_led_ir\n
- * - http://tizen.org/feature/sensor.hrm_led_red\n
+ * - http://tizen.org/feature/sensor.heart_rate_monitor.led_green\n
+ * - http://tizen.org/feature/sensor.heart_rate_monitor.led_ir\n
+ * - http://tizen.org/feature/sensor.heart_rate_monitor.led_red\n
+ * - http://tizen.org/feature/sensor.gyroscope.uncalibrated\n
+ * - http://tizen.org/feature/sensor.magnetometer.uncalibrated\n
+ * - http://tizen.org/feature/sensor.gyroscope_rotation_vector\n
+ * - http://tizen.org/feature/sensor.geomagnetic_rotation_vector\n
*
* It is recommended to design feature related codes in your application for reliability.\n
*
/**
* @brief The sensor handle.
* @details This handle indicates a specific sensor itself.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef void* sensor_h;
/**
* @brief The listener handle.
* @details This listener is an event listener used to receive sensor data asynchronously.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef struct sensor_listener_s *sensor_listener_h;
/**
* @brief The structure type containing information of an event.
* @details It holds information such as timestamp, accuracy, and sensor values.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @remarks If you use proximity sensor, see #sensor_proximity_e
*/
/**
* @brief Enumeration for sensor data accuracy.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
/**
* @brief Enumeration for sensor error.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
/**
* @brief Enumeration for proximity sensor.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
/**
* @brief Enumeration for sensor types.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
SENSOR_ULTRAVIOLET, /**< Ultraviolet sensor */
SENSOR_TEMPERATURE, /**< Temperature sensor */
SENSOR_HUMIDITY, /**< Humidity sensor */
- SENSOR_HRM, /**< Heart Rate Monitor sensor */
- SENSOR_HRM_LED_GREEN, /**< HRM (LED Green) sensor */
- SENSOR_HRM_LED_IR, /**< HRM (LED IR) sensor */
- SENSOR_HRM_LED_RED, /**< HRM (LED RED) sensor */
- SENSOR_GYROSCOPE_UNCALIBRATED, /**< Uncalibrated Gyroscope sensor */
- SENSOR_GEOMAGNETIC_UNCALIBRATED, /**< Uncalibrated Geomagnetic sensor */
- SENSOR_GYROSCOPE_ROTATION_VECTOR, /**< Gyroscope-based Rotation Vector sensor */
- SENSOR_GEOMAGNETIC_ROTATION_VECTOR, /**< Geomagnetic-based Rotation Vector sensor */
+ SENSOR_HRM, /**< Heart Rate Monitor sensor @if MOBILE (Since Tizen 2.3.1) @endif */
+ SENSOR_HRM_LED_GREEN, /**< HRM (LED Green) sensor @if MOBILE (Since Tizen 2.3.1) @endif */
+ SENSOR_HRM_LED_IR, /**< HRM (LED IR) sensor @if MOBILE (Since Tizen 2.3.1) @endif */
+ SENSOR_HRM_LED_RED, /**< HRM (LED RED) sensor @if MOBILE (Since Tizen 2.3.1) @endif */
+ SENSOR_GYROSCOPE_UNCALIBRATED, /**< Uncalibrated Gyroscope sensor (Since Tizen 2.4) */
+ SENSOR_GEOMAGNETIC_UNCALIBRATED, /**< Uncalibrated Geomagnetic sensor (Since Tizen 2.4) */
+ SENSOR_GYROSCOPE_ROTATION_VECTOR, /**< Gyroscope-based rotation vector sensor (Since Tizen 2.4) */
+ SENSOR_GEOMAGNETIC_ROTATION_VECTOR, /**< Geomagnetic-based rotation vector sensor (Since Tizen 2.4) */
SENSOR_LAST, /**< End of sensor enum values */
SENSOR_CUSTOM = 10000 /**< Custom sensor */
} sensor_type_e;
/**
* @brief Enumeration for sensor options.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
#ifndef __SENSOR_COMMON_H__
typedef enum
/**
* @brief Checks whether a given sensor type is available on a device.
* @details Availability of a sensor should be checked first because this sensor may not be supported on the device.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @remarks For getting a handle of HRM Sensor(including HRM_LED_GREEN, HRM_LED_IR and HRM_LED_RED)
* the privilege should be set to, %http://tizen.org/privilege/healthinfo.
*
/**
* @brief Gets a specific sensor handle.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @remarks For getting a handle of HRM Sensor(including HRM_LED_GREEN, HRM_LED_IR and HRM_LED_RED)
* the privilege should be set to, %http://tizen.org/privilege/healthinfo.
*
/**
* @brief Gets a sensor list.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @remarks If you want to get a handle list of all sensors,
* use SENSOR_ALL type in sensor_type_e.
* @remarks The caller should explicitly free this list.
/**
* @brief Called when a sensor event occurs.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] sensor The sensor handle
* @param[in] event The event information
/**
* @brief Creates a sensor listener.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @remarks You must release @a listener using sensor_destroy_listener().
*
/**
* @brief Destroys the sensor handle and releases all its resources.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @remarks After this function is called, the attached sensor is detached and
* the corresponding sensor connection is released.
* @details After this function is called, sensor events will occur and
* the specific sensor type related callback function will be called. An application can read sensor data.
*
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] listener The listener handle
*
*
* @details The given @a type event will not occur any more and the callback functions also won't be called.
*
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] listener The listener handle
*
/**
* @brief Registers a callback function to be invoked when a sensor event occurs.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] listener The listener handle
* @param[in] interval_ms The interval at which sensor events are delivered (in milliseconds) \n
- * If @a rate is zero, it uses the default value(100ms)
+ * If @a rate is zero, it uses the default value(100ms) \n
+ * Min value is 10ms, Max value is 1000ms(10ms ~ 1000ms)
* @param[in] callback The callback function to register
* @param[in] data The user data to be passed to the callback function
*
/**
* @brief Unregisters the sensor callback function.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] listener The listener handle
*
* @details When something is artificially influencing, such as ferrous metal objects or
* electromagnetic fields (car electrical systems, automobile engines, steel pitons, and so on.), this callback is called.
* One way of implementing this callback is to instruct a user to make big 8-like gestures with the device.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] sensor The sensor handle
* @param[in] timestamp The time in milliseconds at which the event happened
/**
* @brief Registers an accuracy callback function to be invoked when the accuracy of a sensor has changed.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] listener The listener handle
* @param[in] callback The callback function to register
/**
* @brief Unregisters the sensor accuracy changed callback function.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] listener The listener handle
*
/**
* @brief Gets sensor data.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] listener The listener handle
* @param[out] event The event information
/**
* @brief Changes the interval at sensor measurements.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] listener The listener handle
* @param[in] interval_ms The interval at which sensor events are delivered (in milliseconds) \n
- * If @a rate is zero, it uses the default value(100ms)
+ * If @a rate is zero, it uses the default value(100ms) \n
+ * Min value is 10ms, Max value is 1000ms(10ms ~ 1000ms)
*
* @return @c 0 on success,
* otherwise a negative error value
/**
* @brief Changes the max batch latency at sensor measurements.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] listener The listener handle
* @param[in] max_batch_latency The latency at which sensor events are delivered (in milliseconds)
/**
* @brief Changes the option of the sensor.
* @details If it is default, sensor data cannot be recieved when the LCD is off and in the power save mode.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] listener The listener handle
* @param[in] option The sensor option
/**
* @brief Gets the name of the sensor.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] sensor The sensor handle
* @param[out] name The name of the sensor
/**
* @brief Gets the vendor of the sensor.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] sensor The sensor handle
* @param[out] vendor The vendor of the sensor
/**
* @brief Gets the type of the sensor.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] sensor The sensor handle
* @param[out] type The type of the sensor
/**
* @brief Gets the minimum range of the sensor.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] sensor The sensor handle
* @param[out] min_range The minimum range
/**
* @brief Gets the maximum range of the sensor.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] sensor The sensor handle
* @param[out] max_range The maximum range
/**
* @brief Gets the resolution of the sensor.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] sensor The sensor handle
* @param[out] resolution The resolution
/**
* @brief Gets the minimun interval of the sensor.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] sensor The sensor handle
* @param[out] min_interval The minimum interval (in milliseconds)
/**
* @brief Gets the fifo count of the sensor.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] sensor The sensor handle
* @param[out] fifo_count The fifo count
/**
* @brief Gets the maximum batch count of the sensor.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] sensor The sensor handle
* @param[out] max_batch_count The maximum batch count
/**
* @brief Enumeration of the axis used in #sensor_util_remap_coordinate_system.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @see #sensor_util_remap_coordinate_system
*/
* [0 m 0] = I * R * geomagnetic (m = magnitude of the geomagnetic field) \n
* R is the identity matrix when the device is aligned with the world's coordinate system, that is, when the device's X axis points towards the East, the Y axis points to the North Pole and the device is facing the sky. \n
* I is a rotation matrix transforming the geomagnetic vector into the same coordinate space as gravity (the world's coordinate space). I is a simple rotation around the X axis. \n
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @remarks Parameters Gx, Gy, and Gz can be obtained from the values returned by #SENSOR_GRAVITY. \n
* Parameters Mx, My, and Mz can be obtained from the values returned by #SENSOR_MAGNETIC.
*
* @details Rotation vectors (Vx, Vy, Vz) can be obtained from #SENSOR_ROTATION_VECTOR.
* It returns a 9 element rotation matrix in the array R. R must have length as 9.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] Vx The X-axis rotation vector
* @param[in] Vy The Y-axis rotation vector
* @brief Rotates the supplied rotation matrix so that it is expressed in a different coordinate system.
*
* @details This is typically used when an application needs to compute the three orientation angles of the device in a different coordinate system.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @remarks inR and outR can be the same array, but this is not recommended for performance reasons.
* This returns an error when X and Y define the same axis.
/**
* @brief Computes the geomagnetic inclination angle in radians from the inclination matrix I returned by sensor_util_get_rotation_matrix().
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] I The inclination matrix from sensor_util_get_rotation_matrix()
* @param[out] inclination The geomagnetic inclination angle in radians
* - values[0]: azimuth, rotation around the Z axis.
* - values[1]: pitch, rotation around the X axis.
* - values[2]: roll, rotation around the Y axis.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @remarks Parameter R must be an array of 9 floats from sensor_util_get_rotation_matrix() \n
* Returned values are always arrays of 3 floats.
* @details Given a current rotation matrix (R) and a previous rotation matrix (prevR), it computes
* the rotation around the x,y, and z axes which transforms prevR to R.
* It outputs a 3 element vector containing the x,y, and z angle change at indexes 0, 1, and 2 respectively. \n
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @remarks Each input matrix is a 3x3 matrix like this form:
* <pre>
/**
* @brief Gets the declination of the horizontal component of the magnetic field from true north, in degrees.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] latitude The latitude in geodetic coordinates
* @param[in] longitude The longitude in geodetic coordinates
Version: 0.1.18
Release: 0
Group: System/API
-License: Apache 2.0
+License: Apache-2.0 and PD
Source0: %{name}-%{version}.tar.gz
Source1: capi-system-sensor.manifest
int getAngleChange(float *R, float *prevR, float *angleChange)
{
- if(R == NULL || prevR == NULL || angleChange == NULL)
+ if (R == NULL || prevR == NULL || angleChange == NULL)
return -1;
- float rd1=0,rd4=0, rd6=0,rd7=0, rd8=0;
- float ri0=0,ri1=0,ri2=0,ri3=0,ri4=0,ri5=0,ri6=0,ri7=0,ri8=0;
- float pri0=0, pri1=0, pri2=0, pri3=0, pri4=0, pri5=0, pri6=0, pri7=0, pri8=0;
+ float rd1, rd4, rd6, rd7, rd8;
+ float ri0, ri1, ri2, ri3, ri4, ri5, ri6, ri7, ri8;
+ float pri0, pri1, pri2, pri3, pri4, pri5, pri6, pri7, pri8;
ri0 = R[0];
ri1 = R[1];
}
int quatToMatrix(float *quat, float *R)
{
- if(quat == NULL || R == NULL)
+ if (quat == NULL || R == NULL)
return -1;
float q0 = quat[0];
int matrixToQuat(float *mat, float *q)
{
- if(q == NULL || mat == NULL)
+ if (q == NULL || mat == NULL)
return -1;
const float Hx = mat[0];
const float My = mat[4];
const float Az = mat[8];
- q[0] = sqrtf( clamp( Hx - My - Az + 1) * 0.25f );
- q[1] = sqrtf( clamp(-Hx + My - Az + 1) * 0.25f );
- q[2] = sqrtf( clamp(-Hx - My + Az + 1) * 0.25f );
- q[3]= sqrtf( clamp( Hx + My + Az + 1) * 0.25f );
+ q[0] = sqrtf(clamp(Hx - My - Az + 1) * 0.25f);
+ q[1] = sqrtf(clamp(-Hx + My - Az + 1) * 0.25f);
+ q[2] = sqrtf(clamp(-Hx - My + Az + 1) * 0.25f);
+ q[3] = sqrtf(clamp(Hx + My + Az + 1) * 0.25f);
q[0] = copysignf(q[0], mat[7] - mat[5]);
q[1] = copysignf(q[1], mat[2] - mat[6]);
q[2] = copysignf(q[2], mat[3] - mat[1]);
int getRotationMatrix(float *accel, float *geo, float *R, float *I)
{
- if(accel == NULL || geo == NULL || R == NULL || I == NULL)
+ if (accel == NULL || geo == NULL || R == NULL || I == NULL)
return -1;
float Ax = accel[0];
float Hy = Ez*Ax - Ex*Az;
float Hz = Ex*Ay - Ey*Ax;
float normH = (float)sqrt(Hx*Hx + Hy*Hy + Hz*Hz);
- if(normH < 0.1f){
+ if (normH < 0.1f) {
return -1;
}
float invH = 1.0f / normH;
I[0] = 1; I[1] = 0; I[2] = 0;
I[3] = 0; I[4] = c; I[5] = s;
- I[6] = 0; I[7] =-s; I[8] = c;
+ I[6] = 0; I[7] = -s; I[8] = c;
return 0;
}
int remapCoordinateSystem(float *inR, int X, int Y, float *outR)
{
- if(inR == NULL || outR == NULL)
+ if (inR == NULL || outR == NULL)
return -1;
- if ((X & 0x7C)!=0 || (Y & 0x7C)!=0)
- return -1; // invalid parameter
- if (((X & 0x3)==0) || ((Y & 0x3)==0))
- return -1; // no axis specified
+ if ((X & 0x7C) != 0 || (Y & 0x7C) != 0)
+ return -1; /* invalid parameter */
+ if (((X & 0x3) == 0) || ((Y & 0x3) == 0))
+ return -1; /* no axis specified */
if ((X & 0x3) == (Y & 0x3))
- return -1; // same axis specified
+ return -1; /* same axis specified */
int Z = X ^ Y;
int x = (X & 0x3)-1;
if (((x^axis_y)|(y^axis_z)) != 0)
Z ^= 0x80;
- char sx = (X>=0x80) ? 1 : 0;
- char sy = (Y>=0x80) ? 1 : 0;
- char sz = (Z>=0x80) ? 1 : 0;
+ char sx = (X >= 0x80) ? 1 : 0;
+ char sy = (Y >= 0x80) ? 1 : 0;
+ char sz = (Z >= 0x80) ? 1 : 0;
int i = 0 , j = 0;
- for (j=0 ; j<3 ; j++) {
- int offset = j*3;
- for (i=0 ; i<3 ; i++) {
- if (x==i) outR[offset+i] = sx ? -inR[offset+0] : inR[offset+0];
- if (y==i) outR[offset+i] = sy ? -inR[offset+1] : inR[offset+1];
- if (z==i) outR[offset+i] = sz ? -inR[offset+2] : inR[offset+2];
+ for (j = 0 ; j < 3 ; j++) {
+ int offset = j * 3;
+ for (i = 0 ; i < 3 ; i++) {
+ if (x == i) outR[offset+i] = sx ? -inR[offset+0] : inR[offset+0];
+ if (y == i) outR[offset+i] = sy ? -inR[offset+1] : inR[offset+1];
+ if (z == i) outR[offset+i] = sz ? -inR[offset+2] : inR[offset+2];
}
}
return 0;
float g_declination = 0;
float g_inclination = 0;
-static void E0000(int IENTRY, int maxdeg, float alt,float glat,float glon, float time, float *dec, float *dip, float *ti, float *gv);
+static void E0000(int IENTRY, int maxdeg, float alt, float glat, float glon, float time, float *dec, float *dip, float *ti, float *gv);
int getDeclination(float *decl)
{
- if(decl == NULL)
+ if (decl == NULL)
return -1;
*decl = g_declination;
int getInclination(float *incl)
{
- if(incl == NULL)
+ if (incl == NULL)
return -1;
*incl = g_inclination;
{
float dec, dip, ti, gv;
float h;
- float rTd=0.017453292;
+ float rTd = 0.017453292;
- E0000(0,12,0.0,0.0,0.0,0.0,NULL,NULL,NULL,NULL);
- E0000(1,0,altitude,latitude,longitude,2,&dec,&dip,&ti,&gv);
+ E0000(0, 12, 0.0, 0.0, 0.0, 0.0, NULL, NULL, NULL, NULL);
+ E0000(1, 0, altitude, latitude, longitude, 2, &dec, &dip, &ti, &gv);
- h=ti*(cos((dip*rTd)));
+ h = ti*(cos((dip*rTd)));
/* deal with geographic and magnetic poles */
- if (h < 100.0) /* at magnetic poles */
- {
+ if (h < 100.0) { /* at magnetic poles */
dec = 0;
}
- if(option == 1)
- {
- if(declination != NULL)
+ if (option == 1) {
+ if (declination != NULL)
*declination = dec;
- if(inclination != NULL)
+ if (inclination != NULL)
*inclination = dip;
- }
- else if( option == 0)
- {
+ } else if (option == 0) {
g_declination = dec;
g_inclination = dip;
}
static void E0000(int IENTRY, int maxdeg, float alt, float glat, float glon, float time, float *dec, float *dip, float *ti, float *gv)
{
- static int maxord,n,m,j,D1,D2,D3,D4;
- static float tc[13][13],dp[13][13],snorm[169],
- sp[13],cp[13],fn[13],fm[13],pp[13],k[13][13],pi,dtr,a,b,re,
- a2,b2,c2,a4,b4,c4,flnmj,otime,oalt,
- olat,olon,dt,rlon,rlat,srlon,srlat,crlon,crlat,srlat2,
- crlat2,q,q1,q2,ct,st,r2,r,d,ca,sa,aor,ar,br,bt,bp,bpp,
- par,temp1,temp2,parp,bx,by,bz,bh;
+ static int maxord, n, m, j, D1, D2, D3, D4;
+ static float tc[13][13], dp[13][13], snorm[169],
+ sp[13], cp[13], fn[13], fm[13], pp[13], k[13][13], pi, dtr, a, b, re,
+ a2, b2, c2, a4, b4, c4, flnmj, otime, oalt,
+ olat, olon, dt, rlon, rlat, srlon, srlat, crlon, crlat, srlat2,
+ crlat2, q, q1, q2, ct, st, r2, r, d, ca, sa, aor, ar, br, bt, bp, bpp,
+ par, temp1, temp2, parp, bx, by, bz, bh;
static float *p = snorm;
- switch(IENTRY){case 0: goto GEOMAG; case 1: goto GEOMG1;}
+ switch (IENTRY) {case 0: goto GEOMAG; case 1: goto GEOMG1; }
GEOMAG:
maxord = 12;
*snorm = 1.0;
fm[0] = 0.0;
- for (n=1; n<=maxord; n++)
- {
+ for (n = 1; n <= maxord; n++) {
*(snorm+n) = *(snorm+n-1)*(float)(2*n-1)/(float)n;
j = 2;
- for (m=0,D1=1,D2=(n-m+D1)/D1; D2>0; D2--,m+=D1)
- {
+ for (m = 0, D1 = 1, D2 = (n-m+D1)/D1; D2 > 0; D2--, m += D1) {
k[m][n] = (float)(((n-1)*(n-1))-(m*m))/(float)((2*n-1)*(2*n-3));
- if (m > 0)
- {
+ if (m > 0) {
flnmj = (float)((n-m+1)*j)/(float)(n+m);
*(snorm+n+m*13) = *(snorm+n+(m-1)*13)*sqrt(flnmj);
j = 1;
sp[1] = srlon;
cp[1] = crlon;
- if (alt != oalt || glat != olat)
- {
+ if (alt != oalt || glat != olat) {
q = sqrt(a2-c2*srlat2);
q1 = alt*q;
q2 = ((q1+a2)/(q1+b2))*((q1+a2)/(q1+b2));
ca = (alt+d)/r;
sa = c2*crlat*srlat/(r*d);
}
- if (glon != olon)
- {
- for (m=2; m<=maxord; m++)
- {
+ if (glon != olon) {
+ for (m = 2; m <= maxord; m++) {
sp[m] = sp[1]*cp[m-1]+cp[1]*sp[m-1];
cp[m] = cp[1]*cp[m-1]-sp[1]*sp[m-1];
}
aor = re/r;
ar = aor*aor;
br = bt = bp = bpp = 0.0;
- for (n=1; n<=maxord; n++)
- {
+ for (n = 1; n <= maxord; n++) {
ar = ar*aor;
- for (m=0,D3=1,D4=(n+m+D3)/D3; D4>0; D4--,m+=D3)
- {
- if (alt != oalt || glat != olat)
- {
- if (n == m)
- {
+ for (m = 0, D3 = 1, D4 = (n+m+D3)/D3; D4 > 0; D4--, m += D3) {
+ if (alt != oalt || glat != olat) {
+ if (n == m) {
*(p+n+m*13) = st**(p+n-1+(m-1)*13);
dp[m][n] = st*dp[m-1][n-1]+ct**(p+n-1+(m-1)*13);
goto S50;
}
- if (n == 1 && m == 0)
- {
+ if (n == 1 && m == 0) {
*(p+n+m*13) = ct**(p+n-1+m*13);
dp[m][n] = ct*dp[m][n-1]-st**(p+n-1+m*13);
goto S50;
}
- if (n > 1 && n != m)
- {
+ if (n > 1 && n != m) {
if (m > n-2) *(p+n-2+m*13) = 0.0;
if (m > n-2) dp[m][n-2] = 0.0;
*(p+n+m*13) = ct**(p+n-1+m*13)-k[m][n]**(p+n-2+m*13);
}
}
S50:
- if (time != otime)
- {
+ if (time != otime) {
tc[m][n] = c[m][n]+dt*cd[m][n];
if (m != 0) tc[n][m-1] = c[n][m-1]+dt*cd[n][m-1];
}
par = ar**(p+n+m*13);
- if (m == 0)
- {
+ if (m == 0) {
temp1 = tc[m][n]*cp[m];
temp2 = tc[m][n]*sp[m];
- }
- else
- {
+ } else {
temp1 = tc[m][n]*cp[m]+tc[n][m-1]*sp[m];
temp2 = tc[m][n]*sp[m]-tc[n][m-1]*cp[m];
}
bp += (fm[m]*temp2*par);
br += (fn[n]*temp1*par);
- if (st == 0.0 && m == 1)
- {
+ if (st == 0.0 && m == 1) {
if (n == 1) pp[n] = pp[n-1];
else pp[n] = ct*pp[n-1]-k[m][n]*pp[n-2];
parp = ar*pp[n];
bz = bt*sa-br*ca;
bh = sqrt((bx*bx)+(by*by));
*ti = sqrt((bh*bh)+(bz*bz));
- *dec = atan2(by,bx)/dtr;
- *dip = atan2(bz,bh)/dtr;
+ *dec = atan2(by, bx)/dtr;
+ *dip = atan2(bz, bh)/dtr;
*gv = -999.0;
- if (fabs(glat) >= 55.)
- {
+ if (fabs(glat) >= 55.) {
if (glat > 0.0 && glon >= 0.0) *gv = *dec-glon;
if (glat > 0.0 && glon < 0.0) *gv = *dec+fabs(glon);
if (glat < 0.0 && glon >= 0.0) *gv = *dec+glon;