This page has been translated automatically.
Видеоуроки
Интерфейс
Основы
Продвинутый уровень
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Профессиональный уровень (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Контроль версий
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Player-ноды
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Материалы и шейдеры
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
API
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Учебные материалы

Math 2D Functions

This class represents a collection of two-dimensional math functions.

Notice
Math 2D functions are the members of the Unigine.MathLib namespace.

Math Class

Members


bool SetPolygonToCCW ( vec2[] OUT_points ) #

Sets the counter-clockwise orientation for the polygon.

Arguments

  • vec2[] OUT_points - Array containing all points of the polygon.
    Notice
    This output buffer is to be filled by the Engine as a result of executing the method.

Return value

true if the counter-clockwise orientation for the polygon is set successfully; otherwise, false.

void TriangulatePolygon ( vec2[] points, unsigned short[] OUT_indices, bool append_to_result ) #

Performs triangulation by ear clipping algorithm (complexity: O(n^2)/O(n)).

Arguments

  • vec2[] points - Array containing all points of the polygon.
  • unsigned short[] OUT_indices - Vector containing all points indices.
    Notice
    This output buffer is to be filled by the Engine as a result of executing the method.
  • bool append_to_result - Flag indicating if resulting points should be appended to the points of initial polygon - false (the default value), or replace them - true.

void ResizePolygon ( vec2[] points, float offset, vec2[] OUT_result_points, bool append_to_result ) #

Returns a set of points representing a shrunk/enlarged polygon. Supports concave polygons, CCW and CW orientations.

Arguments

  • vec2[] points - Array containing all points of the polygon.
  • float offset
  • vec2[] OUT_result_points - Array containing all points of the shrunk/enlarged polygon.
    Notice
    This output buffer is to be filled by the Engine as a result of executing the method.
  • bool append_to_result - Flag indicating if resulting points should be appended to the points of initial polygon - false (the default value), or replace them - true.

float GetPolygonArea ( vec2[] points ) #

Returns the area of the given polygon in square units.

Arguments

  • vec2[] points - Array containing all points of the polygon.

Return value

Polygon's area, in square units.

float GetPolygonAreaSigned ( vec2[] points ) #

Returns the area of the given polygon in square units.

Arguments

  • vec2[] points - Array containing all points of the polygon.

Return value

Polygon's area, in square units.
Notice
The value will be negative if the polygon is oriented clockwise.

void FindIntersection ( vec2 p1, vec2 p2, vec2 p3, vec2 p4, out bool lines_intersect, out bool segments_intersect, out vec2 intersection, out vec2 close_p1, out vec2 close_p2 ) #

Finds the point of intersection between the two lines specified by the pairs of points p1 - p2 and p3 - p4 and sets the values of the last 5 arguments.

Arguments

  • vec2 p1 - Start point coordinates of the first line segment.
  • vec2 p2 - End point coordinates of the first line segment.
  • vec2 p3 - Start point coordinates of the second line segment.
  • vec2 p4 - End point coordinates of the second line segment.
  • out bool lines_intersect - true if the lines to which the segments belong intersect; otherwise, false.
  • out bool segments_intersect - true if the lines to which the segments belong intersect; otherwise, false.
  • out vec2 intersection - Coordinates of the point of intersection between the two line segments.
  • out vec2 close_p1 - Coordinates of the first of the two closest points belonging to the first segment.
  • out vec2 close_p2 - Coordinates of the second of the two closest points belonging to the second segment.

bool PolygonIsOrientedClockwise ( vec2[] points ) #

Returns a value indicating if a given polygon is oriented clockwise.

Arguments

  • vec2[] points - Array containing all points of the polygon.

Return value

true if a given polygon is oriented clockwise; otherwise, false.

float GetTriangleArea ( vec2 p1, vec2 p2, vec2 p3 ) #

Returns the area of the given triangle in square units.

Arguments

  • vec2 p1 - Coordinates of the first triangle vertex.
  • vec2 p2 - Coordinates of the second triangle vertex.
  • vec2 p3 - Coordinates of the third triangle vertex.

Return value

Triangle area, in square units.
Notice
The value will be negative if the polygon is oriented clockwise.

float Sign ( vec2 point, vec2 segment_p1, vec2 segment_p2 ) #

Returns a value indicating to which part of the segment the point belongs.

Arguments

  • vec2 point - Coordinates of the point to be checked.
  • vec2 segment_p1 - Segment start point coordinates.
  • vec2 segment_p2 - Segment end point coordinates.

bool PointTriangleInside ( vec2 point, vec2 v0, vec2 v1, vec2 v2 ) #

Returns a value indicating if a given point is inside the specified triangle.

Arguments

  • vec2 point - Coordinates of the point to be checked.
  • vec2 v0 - Coordinates of the first triangle vertex.
  • vec2 v1 - Coordinates of the second triangle vertex.
  • vec2 v2 - Coordinates of the third triangle vertex.

Return value

true if a given point is inside the specified triangle; otherwise, false.
Last update: 19.04.2024
Build: ()