public ExtPlane3d(Vector3 position, Vector3 normal) : this() { _position = position; _rotation = ExtRotation.QuaternionFromVectorDirector(normal, Vector3.up); _rotation = ExtRotation.RotateQuaternion(_rotation, new Vector3(-90, 0, 0)); UpdateMatrix(); }
/// 2 ------2------ 3 /// 1 | 3 | /// 1 ------4----- 4 | /// | | 3 | | /// | 4| | 2 | /// | 1 | /// | | /// public ExtQuad(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4) : this() { _position = ExtVector3.GetMeanOfXPoints(p1, p2, p3, p4); Vector3 x = p1 - p2; Vector3 y = p1 - p4; Vector3 up = Vector3.Cross(x, y); _rotation = ExtRotation.QuaternionFromVectorDirector(up, x.FastNormalized()); _rotation = ExtRotation.RotateQuaternion(_rotation, new Vector3(-90, 0, 0)); _localScale = new Vector3(y.magnitude, 1, x.magnitude); UpdateMatrix(); }
public ExtCylinder(Vector3 p1, Vector3 p2, float radius = 0.25f) : this() { _position = ExtVector3.GetMeanOfXPoints(p1, p2); _rotation = ExtQuaternion.QuaternionFromLine(p1, p2, Vector3.up); _rotation = ExtRotation.RotateQuaternion(_rotation, new Vector3(90, 0, 0)); _localScale = new Vector3(1, 1, 1); _cylinderMatrix = Matrix4x4.TRS(_position, _rotation, _localScale * 1); //why radius a 0.25, and lenght * 0.8 ?? I don't know, //it's there to match the first constructor(position, rotation, scale) _radius = radius; _lenght = ExtVector3.Distance(p2, p1) * 0.8f; _lenghtSquared = _lenght * _lenght; _radiusSquared = _radius * _radius; _realRadius = _radius * MaxXY(_localScale); _realSquaredRadius = _realRadius * _realRadius; UpdateMatrix(); }