Last active
June 14, 2021 09:41
-
-
Save guitarrapc/29ae16f98661350e082d8d83720ccc02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var lb = new Vector2(1.1f, 2.2f); | |
var rt = new Vector2(5.6f, 3.4f); | |
ToCeilAndFlooredBoundingBox(lb, rt); | |
} | |
public static (Vector2, Vector2) ToCeilAndFlooredBoundingBox(Vector2 lb, Vector2 rt) | |
{ | |
return (new Vector2((float)Math.Ceiling(lb.X), (float)Math.Ceiling(lb.Y)), | |
new Vector2((float)Math.Floor(rt.X), (float)Math.Floor(rt.Y))); | |
} | |
// zatsu | |
public struct Vector2 | |
{ | |
public float X; | |
public float Y; | |
public Vector2(float x, float y) | |
{ | |
(X, Y) = (x, y); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var lb = new Vector2(1.1f, 2.2f); | |
var rt = new Vector2(5.6f, 3.4f); | |
ToCeilAndFlooredBoundingBox((lb, rt)); | |
} | |
public static (Vector2, Vector2) ToCeilAndFlooredBoundingBox((Vector2 lb, Vector2 rt) tpl) | |
{ | |
// deconstruct | |
var (l, r) = tpl; | |
return (new Vector2((float)Math.Ceiling(l.X), (float)Math.Ceiling(l.Y)), | |
new Vector2((float)Math.Floor(r.X), (float)Math.Floor(r.Y))); | |
} | |
// zatsu | |
public struct Vector2 | |
{ | |
public float X; | |
public float Y; | |
public Vector2(float x, float y) | |
{ | |
(X, Y) = (x, y); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment