3d vector struct

Martijn Pot martijnpot52 at gmail.com
Mon Feb 3 12:47:42 PST 2014


On Monday, 3 February 2014 at 20:10:59 UTC, Brenton wrote:

> 	double dot(in Vector3d other) inout {
> 		return x * other.x + y * other.y + z * other.z;
> 	}
> 	Vector3d cross(in Vector3d other) inout {
> 		const Vector3d result = {
> 			y * other.z - z * other.y,
> 			z * other.x - x * other.z,
> 			x * other.y - y * other.x
> 		};
> 		return result;
> 	}
> }

Shouldn't these functions be non-member:

double dot(in Vector3d one, in Vector3d other) {}
Vector3d cross(in Vector3d one, in Vector3d other) {}

No one Vector3d is more special in these functions, so treat them 
equal.


More information about the Digitalmars-d-learn mailing list