搜尋套件、儲存庫與 APP 分類

套件詳情v0.2.0

superdeclarative_geometry

對角度、極座標等的一流支援。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
27
喜歡數
32
Pub 分數
150

安裝套件

flutter pub add superdeclarative_geometry

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

superdeclarative_geometry 是一個 Dart 套件,提供對角度、極座標和幾何計算的一流支援。此套件設計用於精確性和易用性,提供直覺的 API 來處理旋轉數學、向量變換和座標系統轉換。適用於需要高階幾何處理的應用程式,例如動畫、遊戲開發或資料視覺化。該套件具備跨平台特性,支援 Android、iOS、Web、macOS、Windows 和 Linux,使其在各種裝置上的 Flutter 專案中非常靈活。

適用情境

  • 2D/3D 圖形渲染
  • 互動式UI動畫
  • 遊戲開發機制
  • 資料可視化中的徑向佈局
  • 坐標系轉換
  • 旋轉物理模擬

主要特色

  • 原生角度和極坐標類型
  • 高效的幾何變換
  • 跨平台相容性
  • 簡潔、易讀的 API 設計
  • 支援弧度與角度
  • 內建的轉換工具

適合對象

  • Flutter 開發人員使用幾何
  • 需要精確旋轉的UI/UX設計師
  • 需要向量數學的游戏開發者
  • 可視化工具創建者
  • 涉及數學概念的教育類應用程式

使用建議

  • 需要理解極座標和角度數學
  • 可能會為簡單的線性佈局增加額外負擔
  • 最適合具有幾何複雜性的專案
  • 未針對高頻率即時計算進行優化
  • 除了基本範例之外,文件內容有限

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

SuperDeclarative Geometry

First-class support for angles, polar coordinates, and related math.


If you get value from this package, please consider supporting SuperDeclarative!


Get Started

pub

dependencies:
  superdeclarative_geometry: ^[VERSION]

Quick Reference

Angles

Create an Angle from degrees or radians:

final degreesToRadians = Angle.fromDegrees(45);
final radiansToDegrees = Angle.fromRadians(pi / 4);

Retrieve Angle values as degrees or radians:

myAngle.degrees;
myAngle.radians;

Determine an Angle's direction and force it to be positive or negative:

myAngle.isPositive;
myAngle.isNegative;

myAngle.makePositive(); // Ex: -270° ->  90°
myAngle.makeNegative(); // Ex:  270° -> -90°

Determine the category of an Angle:

myAngle.isAcute;
myAngle.isObtuse;
myAngle.isReflexive;
myAngle.category;

Determine if two Angles are equivalent, regardless of direction:

Angle.fromDegrees(90).isEquivalentTo(Angle.fromDegrees(-270));

Invert, add, subtract, multiply, and divide Angles:

-Angle.fromDegrees(30);

Angle.fromDegrees(30) + Angle.fromDegrees(15);

Angle.fromDegrees(30) - Angle.fromDegrees(15);

Angles.fromDegrees(45) * 2;

Angles.fromDegrees(90) / 2;

Rotate an Angle:

final Rotation rotation = myAngle.rotate(Angle.fromDegrees(150));

Rotations

Angles are confined to values in (-360°, 360°). For values beyond this range, the concept of a Rotation is provided.

A Rotation is almost identical to an Angle except that a Rotation can be arbitrarily large in the positive or negative direction. This allows for the accumulation of turns over time.

Create a Rotation:

final rotation = Rotation.fromDegrees(540);

Add, subtract, multiply, and divide Rotations just like Angles.

Reduce a Rotation to an Angle:

Rotation.fromDegrees(540).reduceToAngle();

Polar Coordinates

Define polar coordinates by a radius and an angle, or by a Cartesian point:

PolarCoord(100, PolarCoord.fromDegrees(45));

CartesianPolarCoords.fromPoint(Point(0, 100));

Add, subtract, multiply, and divide PolarCoords:

PolarCoord(100, Angle.fromDegrees(45)) + PolarCoord(200, Angle.fromDegrees(135));

PolarCoord(100, Angle.fromDegrees(45)) - PolarCoord(200, Angle.fromDegrees(135));

PolarCoord(100, Angle.fromDegrees(15)) * 2;

PolarCoord(200, Angle.fromDegrees(30)) / 2;

Map a PolarCoord to a Cartesian Point:

// Map to Cartesian coordinates.
final Point point = PolarCoord(100, Angle.fromDegrees(45)).toCartesian();

Cartesian Orientations

Different use-cases treat angles in different ways.

Mathematics treats the positive x-axis as a 0° angle and treats positive angles as running counter-clockwise.

Flutter app screens treat the positive x-axis as a 0° angle, but then treats positive angles as running clockwise.

Ship navigation treats the positive y-axis as a 0° angle and then treats positive angles as running clockwise.

Each of these situations apply a different orientation when mapping an angle, or a polar coordinate, to a location in Cartesian space. This concept of orientation is supported by superdeclarative_geometry by way of CartesianOrientations.

Both Angle and PolarCoord support CartesianOrientation mappings.

final polarCoord = PolarCoord(100, Angle.fromDegrees(30));

// Treat angles like a Flutter screen.
// This point is 30° clockwise from the x-axis.
final screenPoint = polarCoord.toCartesian(); // defaults to "screen" orientation

// Treat angles like mathematics.
// This point is 30° counter-clockwise from the x-axis.
final mathPoint = polarCoord.toCartesian(orientation: CartesianOrientation.math);

// Treat angles like navigators.
// This point is 30° clockwise from the y-axis.
final navigationPoint = polarCoord.toCartesian(orientation: CartesianOrientation.navigation);

You can define a custom CartesianOrientation by implementing the interface. Then, you can pass an instance of your custom orientation into PolarCoord's toCartesian() method.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。