Utility topic
Utility Module
Dart's standard math
module provides trigonometric functions (sine, cosine, tangent) that operate on angles expressed in radians.
As humans often find it more intuitive to work with angles in degrees (e.g., 360° for a full circle), this module offers helper methods to simplify trigonometric calculations using degree-based inputs.
Also, the methods and functions in Bullseye2D
take angles always in degree (for example the gfx.rotate
or gfx.drawImage
method).
Additionally, this module includes Rect
, a generic class for representing rectangular areas and various extension and helpers.
Classes
Extensions
- BitmaskExtension on int Utility
- Provides extension methods for bitmask operations on integers.
-
SumListExtension
on List<
num> Utility -
Extension on
List<num>
to provide utility methods for calculations.
Functions
-
atan2Degree(
num a, num b) → double Utility -
Calculates the angle in degrees for the point (b, a) using
atan2(a, b)
. -
cosDegree(
num degree) → double Utility -
Calculates the cosine of an angle given in
degree
s. -
nextPowerOfTwo(
int v) → int Utility -
Calculates the next power of two greater than or equal to the given integer
v
. -
sinDegree(
num degree) → double Utility -
Calculates the sine of an angle given in
degree
s. -
stopEvent(
Event event) → void Utility - Stops the propagation and prevents the default action of a browser Event.
-
tanDegree(
num degree) → double Utility -
Calculates the tangent of an angle given in
degree
s.