I’m working on a display library which in most cases works on a 2D plane but it has some components which display 2D projections of a 3D space.
This domain has the notion of Position
, Size
, Position3D
and Size3D
.
Position
and Size
are straightforward:
data class Position(val x: Int, val y: Int) data class Size(val width: Int, val height: Int)
but when I introduce the 3D variants height
is no longer self-explanatory:
data class Position3D(val x: Int, val y: Int, val z: Int) data class Size3D(val width: Int, // this is OK val height: Int, // is this the Y or the Z axis? val depth: Int) // is depth universally recognized?
Is there a best practice for this problem?
I can work around it by doing something like this:
data class Size3D(val xAmount: Int, val yAmount: Int, val zAmount: Int)
but it feels a bit hacky.
How can I solve this?