Merge pull request #18613 from KellyThomas/vector-methods-csharp

round / ceil methods for c sharp vectors
This commit is contained in:
Max Hilbrunner 2018-05-05 20:52:16 +02:00 committed by GitHub
commit 2bf71d0eea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -97,6 +97,11 @@ namespace Godot
return -Reflect(n); return -Reflect(n);
} }
public Vector2 Ceil()
{
return new Vector2(Mathf.Ceil(x), Mathf.Ceil(y));
}
public Vector2 Clamped(real_t length) public Vector2 Clamped(real_t length)
{ {
var v = this; var v = this;
@ -190,6 +195,11 @@ namespace Godot
return new Vector2(Mathf.Cos(rads), Mathf.Sin(rads)) * Length(); return new Vector2(Mathf.Cos(rads), Mathf.Sin(rads)) * Length();
} }
public Vector2 Round()
{
return new Vector2(Mathf.Round(x), Mathf.Round(y));
}
public void Set(real_t x, real_t y) public void Set(real_t x, real_t y)
{ {
this.x = x; this.x = x;

View File

@ -219,6 +219,11 @@ namespace Godot
return 2.0f * n * Dot(n) - this; return 2.0f * n * Dot(n) - this;
} }
public Vector3 Round()
{
return new Vector3(Mathf.Round(x), Mathf.Round(y), Mathf.Round(z));
}
public Vector3 Rotated(Vector3 axis, real_t phi) public Vector3 Rotated(Vector3 axis, real_t phi)
{ {
return new Basis(axis, phi).Xform(this); return new Basis(axis, phi).Xform(this);