Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
魔术师Dix
Unity几何库:木蝴蝶
提交
3781d021
Unity几何库:木蝴蝶
项目概览
魔术师Dix
/
Unity几何库:木蝴蝶
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Unity几何库:木蝴蝶
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3781d021
编写于
10月 19, 2023
作者:
魔术师Dix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新API;
上级
816d22df
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
103 addition
and
49 deletion
+103
-49
Common/Utils.cs
Common/Utils.cs
+82
-0
Math/Extensions.Math.cs
Math/Extensions.Math.cs
+21
-49
未找到文件。
Common/Utils.cs
浏览文件 @
3781d021
...
@@ -390,6 +390,88 @@ namespace Oroxylum
...
@@ -390,6 +390,88 @@ namespace Oroxylum
return
x
+
z
;
return
x
+
z
;
}
}
public
static
Vector2
XZ
(
this
Vector3
pos
)
{
return
new
Vector2
(
pos
.
x
,
pos
.
z
);
}
public
static
Vector2
XY
(
this
Vector3
pos
)
{
return
new
Vector2
(
pos
.
x
,
pos
.
y
);
}
public
static
Vector2
ZY
(
this
Vector3
pos
)
{
return
new
Vector2
(
pos
.
z
,
pos
.
y
);
}
/// <summary>
/// 看向某个目标时,旋转的欧拉角
/// </summary>
/// <param name="pos"></param>
/// <param name="target">目标点</param>
/// <returns>旋转欧拉角</returns>
public
static
Vector3
LookAtEulerAngle
(
this
Vector3
pos
,
Vector3
target
)
{
Vector3
fwd
=
target
-
pos
;
return
Quaternion
.
LookRotation
(
fwd
,
Vector3
.
up
).
eulerAngles
;
}
public
static
int
ToInt
(
this
long
val
)
{
//极值判定;
if
(
val
>
int
.
MaxValue
)
{
Logger
.
LogError
(
$"传入值过大:
{
val
}
"
);
return
int
.
MaxValue
;
}
if
(
val
<
int
.
MinValue
)
{
Logger
.
LogError
(
$"传入值过小:
{
val
}
"
);
return
int
.
MinValue
;
}
return
System
.
Convert
.
ToInt32
(
val
);
}
public
static
int
Add
(
this
int
a
,
long
b
)
{
long
addRet
=
a
+
b
;
return
addRet
.
ToInt
();
}
/// <summary>
/// 是否是有效的 Vector3;
/// </summary>
public
static
bool
IsVaild
(
this
Vector3
point
)
{
if
(
float
.
IsNaN
(
point
.
x
)
||
float
.
IsNaN
(
point
.
y
)
||
float
.
IsNaN
(
point
.
z
))
return
false
;
if
(
float
.
IsInfinity
(
point
.
x
)
||
float
.
IsInfinity
(
point
.
y
)
||
float
.
IsInfinity
(
point
.
z
))
return
false
;
return
true
;
}
public
static
Vector3
Div
(
this
Vector3
a
,
Vector3
b
)
{
float
x
=
a
.
x
/
b
.
x
;
float
y
=
a
.
y
/
b
.
y
;
float
z
=
a
.
z
/
b
.
z
;
return
new
Vector3
(
x
,
y
,
z
);
}
public
static
Vector2
Div
(
this
Vector2
a
,
Vector2
b
)
{
float
x
=
a
.
x
/
b
.
x
;
float
y
=
a
.
y
/
b
.
y
;
return
new
Vector2
(
x
,
y
);
}
public
static
Vector3
Mul
(
this
Vector3
a
,
Vector3
b
)
{
float
x
=
a
.
x
*
b
.
x
;
float
y
=
a
.
y
*
b
.
y
;
float
z
=
a
.
z
*
b
.
z
;
return
new
Vector3
(
x
,
y
,
z
);
}
public
static
Vector2
Mul
(
this
Vector2
a
,
Vector2
b
)
{
float
x
=
a
.
x
*
b
.
x
;
float
y
=
a
.
y
*
b
.
y
;
return
new
Vector2
(
x
,
y
);
}
#
endregion
#
endregion
...
...
Math/Extensions.Math.cs
浏览文件 @
3781d021
...
@@ -12,59 +12,16 @@ namespace Oroxylum
...
@@ -12,59 +12,16 @@ namespace Oroxylum
/// <returns></returns>
/// <returns></returns>
public
static
float
Square
(
this
float
value
)
{
return
value
*
value
;
}
public
static
float
Square
(
this
float
value
)
{
return
value
*
value
;
}
public
static
Vector2
XZ
(
this
Vector3
pos
)
{
return
new
Vector2
(
pos
.
x
,
pos
.
z
);
}
public
static
float2
XZ_float2
(
this
Vector3
v
)
{
return
new
float2
(
v
.
x
,
v
.
z
);
}
public
static
float2
XZ_float2
(
this
Vector3
v
)
{
return
new
float2
(
v
.
x
,
v
.
z
);
}
public
static
Vector2
XY
(
this
Vector3
pos
)
{
return
new
Vector2
(
pos
.
x
,
pos
.
y
);
}
public
static
float2
XY_float2
(
this
Vector3
pos
)
{
return
new
float2
(
pos
.
x
,
pos
.
y
);
}
public
static
float2
XY_float2
(
this
Vector3
pos
)
{
return
new
float2
(
pos
.
x
,
pos
.
y
);
}
public
static
Vector2
ZY
(
this
Vector3
pos
)
{
return
new
Vector2
(
pos
.
z
,
pos
.
y
);
}
public
static
float2
ZY_float2
(
this
Vector3
pos
)
{
return
new
float2
(
pos
.
z
,
pos
.
y
);
}
public
static
float2
ZY_float2
(
this
Vector3
pos
)
{
return
new
float2
(
pos
.
z
,
pos
.
y
);
}
/// <summary>
/// 看向某个目标时,旋转的欧拉角
/// </summary>
/// <param name="pos"></param>
/// <param name="target">目标点</param>
/// <returns>旋转欧拉角</returns>
public
static
Vector3
LookAtEulerAngle
(
this
Vector3
pos
,
Vector3
target
)
{
Vector3
fwd
=
target
-
pos
;
return
Quaternion
.
LookRotation
(
fwd
,
Vector3
.
up
).
eulerAngles
;
}
public
static
int
ToInt
(
this
long
val
)
{
//极值判定;
if
(
val
>
int
.
MaxValue
)
{
Logger
.
LogError
(
$"传入值过大:
{
val
}
"
);
return
int
.
MaxValue
;
}
if
(
val
<
int
.
MinValue
)
{
Logger
.
LogError
(
$"传入值过小:
{
val
}
"
);
return
int
.
MinValue
;
}
return
System
.
Convert
.
ToInt32
(
val
);
}
public
static
int
Add
(
this
int
a
,
long
b
)
{
long
addRet
=
a
+
b
;
return
addRet
.
ToInt
();
}
/// <summary>
/// <summary>
/// 是否是有效的 Vector3;
/// 是否是有效的 Vector3;
/// </summary>
/// </summary>
public
static
bool
IsVaild
(
this
Vector
3
point
)
public
static
bool
IsVaild
(
this
float
3
point
)
{
{
if
(
float
.
IsNaN
(
point
.
x
)
||
float
.
IsNaN
(
point
.
y
)
||
float
.
IsNaN
(
point
.
z
))
if
(
float
.
IsNaN
(
point
.
x
)
||
float
.
IsNaN
(
point
.
y
)
||
float
.
IsNaN
(
point
.
z
))
return
false
;
return
false
;
...
@@ -75,22 +32,37 @@ namespace Oroxylum
...
@@ -75,22 +32,37 @@ namespace Oroxylum
return
true
;
return
true
;
}
}
public
static
Vector3
DivByVector3
(
this
Vector3
a
,
Vector
3
b
)
public
static
float3
Div
(
this
float3
a
,
float
3
b
)
{
{
float
x
=
a
.
x
/
b
.
x
;
float
x
=
a
.
x
/
b
.
x
;
float
y
=
a
.
y
/
b
.
y
;
float
y
=
a
.
y
/
b
.
y
;
float
z
=
a
.
z
/
b
.
z
;
float
z
=
a
.
z
/
b
.
z
;
return
new
Vector3
(
x
,
y
,
z
);
return
new
float3
(
x
,
y
,
z
);
}
public
static
float2
Div
(
this
float2
a
,
float2
b
)
{
float
x
=
a
.
x
/
b
.
x
;
float
y
=
a
.
y
/
b
.
y
;
return
new
float2
(
x
,
y
);
}
}
public
static
Vector3
MulByVector3
(
this
Vector3
a
,
Vector
3
b
)
public
static
float3
Mul
(
this
float3
a
,
float
3
b
)
{
{
float
x
=
a
.
x
*
b
.
x
;
float
x
=
a
.
x
*
b
.
x
;
float
y
=
a
.
y
*
b
.
y
;
float
y
=
a
.
y
*
b
.
y
;
float
z
=
a
.
z
*
b
.
z
;
float
z
=
a
.
z
*
b
.
z
;
return
new
Vector
3
(
x
,
y
,
z
);
return
new
float
3
(
x
,
y
,
z
);
}
}
public
static
float2
Mul
(
this
float2
a
,
float2
b
)
{
float
x
=
a
.
x
*
b
.
x
;
float
y
=
a
.
y
*
b
.
y
;
return
new
float2
(
x
,
y
);
}
public
static
long
Int2ToLong
(
int2
v
)
public
static
long
Int2ToLong
(
int2
v
)
{
{
int
q
=
v
.
x
,
r
=
v
.
y
;
int
q
=
v
.
x
,
r
=
v
.
y
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录