This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
专业(SIM)
UnigineEditor
界面概述
资源工作流程
版本控制
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
Tutorials

Math 2D Functions

Header: #include <UnigineMath2d.h>

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

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

Math Class

Members


int setPolygonToCCW ( Vector<vec2> & OUT_points ) #

Sets the counter-clockwise orientation for the polygon.

Arguments

  • Vector<vec2> & OUT_points - Vector 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

1 if the counter-clockwise orientation for the polygon is set successfully; otherwise, 0.

void triangulatePolygon ( const Vector<vec2> & points, Vector<unsigned short> & OUT_indices, int append_to_result ) #

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

Arguments

  • const Vector<vec2> & points - Vector containing all points of the polygon.
  • Vector<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.
  • int append_to_result - Flag indicating if resulting points should be appended to the points of initial polygon - 0 (the default value), or replace them - 1.

void resizePolygon ( const Vector<vec2> & points, float offset, Vector<vec2> & OUT_result_points, int append_to_result ) #

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

Arguments

  • const Vector<vec2> & points - Vector containing all points of the polygon.
  • float offset
  • Vector<vec2> & OUT_result_points - Vector 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.
  • int append_to_result - Flag indicating if resulting points should be appended to the points of initial polygon - 0 (the default value), or replace them - 1.

float getPolygonArea ( const Vector<vec2> & points ) #

Returns the area of the given polygon in square units.

Arguments

  • const Vector<vec2> & points - Vector containing all points of the polygon.

Return value

Polygon's area, in square units.

float getPolygonAreaSigned ( const Vector<vec2> & points ) #

Returns the area of the given polygon in square units.

Arguments

  • const Vector<vec2> & points - Vector 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 ( const vec2 & p1, const vec2 & p2, const vec2 & p3, const vec2 & p4, int & lines_intersect, int & segments_intersect, vec2 & intersection, vec2 & close_p1, 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

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

int polygonIsOrientedClockwise ( const Vector<vec2> & points ) #

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

Arguments

  • const Vector<vec2> & points - Vector containing all points of the polygon.

Return value

1 if a given polygon is oriented clockwise; otherwise, 0.

float getTriangleArea ( const vec2 & p1, const vec2 & p2, const vec2 & p3 ) #

Returns the area of the given triangle in square units.

Arguments

  • const vec2 & p1 - Coordinates of the first triangle vertex.
  • const vec2 & p2 - Coordinates of the second triangle vertex.
  • const 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 ( const vec2 & point, const vec2 & segment_p1, const vec2 & segment_p2 ) #

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

Arguments

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

int pointTriangleInside ( const vec2 & point, const vec2 & v0, const vec2 & v1, const vec2 & v2 ) #

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

Arguments

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

Return value

1 if a given point is inside the specified triangle; otherwise, 0.
Last update: 2020-09-23
Build: ()