Math routines.
Below is a code example that uses the trigonometry functions to calculate the coordinate at which the second hand of a watch ends, using seconds from the system time.
GPoint secondHand;
GPoint center;
struct tm *tick_time = ...;
int32_t secondHandLength = ...;
...
int32_t second_angle = TRIG_MAX_ANGLE * tick_time->tm_sec / 60;
secondHand.y = (-cos_lookup(second_angle) * secondHandLength / TRIG_MAX_RATIO) + center.y;
secondHand.x = (sin_lookup(second_angle) * secondHandLength / TRIG_MAX_RATIO) + center.x;
Look-up the sine of the given angle from a pre-computed table.
The angle for which to compute the cosine. The angle value is scaled linearly, such that a value of 0x10000 corresponds to 360 degrees or 2 PI radians.
Look-up the cosine of the given angle from a pre-computed table. This is equivalent to calling sin_lookup(angle + TRIG_MAX_ANGLE / 4)
.
The angle for which to compute the cosine. The angle value is scaled linearly, such that a value of 0x10000 corresponds to 360 degrees or 2 PI radians.
Look-up the arctangent of a given x, y pair The angle value is scaled linearly, such that a value of 0x10000 corresponds to 360 degrees or 2 PI radians.
The largest value that can result from a call to sin_lookup or cos_lookup. For a code example, see the detailed description at the top of this chapter: Math.
Converts from a fixed point value representation to the equivalent value in degrees.
Converts from an angle in degrees to the equivalent fixed point value representation.
Do you have questions about the Pebble SDK?
Do you need some help understanding something on this page?
You can either take advantage of our awesome developer community and check out the SDK Help forums, or you can send us a message through the website!