public class Dimension
{
public int X;
public int Y;
public int Z;
public Dimension(int x, int y, int z) {
X = x;
Y = y;
Z = z;
}
#region Operators
public static Dimension operator +(Dimension dimensionA, Dimension dimensionB) {
return new Dimension(dimensionA.X + dimensionB.X,
dimensionA.Y + dimensionB.Y,
dimensionA.Z + dimensionB.Z);
}
public static Dimension operator -(Dimension dimensionA, Dimension dimensionB) {
return new Dimension(dimensionA.X - dimensionB.X,
dimensionA.Y - dimensionB.Y,
dimensionA.Z - dimensionB.Z);
}
public static Dimension operator *(Dimension dimensionA, Dimension dimensionB) {
return new Dimension(dimensionA.X * dimensionB.X,
dimensionA.Y * dimensionB.Y,
dimensionA.Z * dimensionB.Z);
}
public static Dimension operator /(Dimension dimensionA, Dimension dimensionB) {
return new Dimension(dimensionA.X / dimensionB.X,
dimensionA.Y / dimensionB.Y,
dimensionA.Z / dimensionB.Z);
}
#endregion
}
A ready-to-go Dimension class, so you can specify a 3D point and add, substract, divide or multiply them.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.