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
Materials and Shaders
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
创建内容
内容优化
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine.Math2d Struct

Notice
The functions listed below are the members of the Unigine.MathLib namespace.

Math2d Class

Members


bool SetPolygonToCCW ( List<vec2> points ) #

Sets the counter-clockwise orientation for the polygon.

Arguments

  • List<vec2> points - List containing all points of the polygon.

Return value

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

void TriangulatePolygon ( List<vec2> points, List<ushort> indices, bool append_to_result ) #

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

Arguments

  • List<vec2> points - List containing all points of the polygon.
  • List<ushort> indices - List containing all points indices.
  • 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 ( List<vec2> points, float offset, List<vec2> result_points, bool append_to_result ) #

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

Arguments

  • List<vec2> points - List containing all points of the polygon.
  • float offset
  • List<vec2> result_points - List containing all points of the shrunk/enlarged polygon.
  • 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 FindIntersection ( vec2 p1, vec2 p2, vec2 p3, vec2 p4, bool lines_intersect, bool 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

  • 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.
  • bool lines_intersect - true if the lines to which the segments belong intersect; otherwise, false.
  • bool segments_intersect - true if the lines to which the segments belong intersect; otherwise, false.
  • 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.

bool PolygonIsOrientedClockwise ( List<vec2> points ) #

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

Arguments

  • List<vec2> points - List containing all points of the polygon.

Return value

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

float GetPolygonAreaSigned ( List<vec2> points ) #

Returns the area of the given polygon in square units.

Arguments

  • List<vec2> points - List 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.

float GetPolygonArea ( List<vec2> points ) #

Returns the area of the given polygon in square units.

Arguments

  • List<vec2> points - List containing all points of the polygon.

Return value

Polygon's area, in square units.

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 an integral value indicating the sign of an argument.

Arguments

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

Return value

Resulting float value.

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

Checks if a point is inside a 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: 2022-10-10
Build: ()