Physics

Revision 3 as of 2011-08-11 16:52:07

Clear message

Library: uTouch-Physics Language: C Dependencies: ODE

Units

Screen coordinates make more sense than real-world coordinates. If you have a 30" monitor next to a 24" monitor, both with equal resolutions, scrolling should move the content the same amount in screen coordinates. To facilitate this, units of pixels are used for distance.

A 24" 1080p monitor is a typical size and resolution for a desktop computer. This works out to 3614 px/m in the diagonal direction. We will assume square pixels. Thus, a reasonable conversion from meters to pixels is about 3.5 MP/m (where MP is a mega-pixel, or 1000 pixels).

Types

uphys

Handle for uTouch-Physics context.

uphys_rect

Holds the origin and size of a rectangle.

uphys Properties

error: int

Error code from last function call.

Set to 0 on success.

error_string: const char *

Error string from last function call.

Set to "no error" on success.

gravity: float

Defaults to 34.3 MP/s2. This is calculated by multiplying the standard earth gravity of 9.8 m/s2 by the standard conversion from meters to pixels of 3.5 MP/m.

(scrollview) viewport: uphys_rect

The rectangle of the viewport within the scrollview content.

(scrollview) content: uphys_rect

The rectangle of the content of the scrollview.

Functions

int uphys_set_property(uphys *uphys, const char *name, void *value)

Set a property value.

Returns 0 if successful, non-zero on error.

int uphys_get_property(const uphys *uphys, const char *name, void *value)

Get a property value.

Returns 0 if successful, non-zero on error.

uphys *uphys_new_scrollview()

Create a new uphys context for a scrollable viewport.

Returns a new context or NULL on error.