Dart Documentationvector_mathAabb3

Aabb3 class

class Aabb3 {
 Vector3 _min;
 Vector3 _max;

 Vector3 get min => _min;
 Vector3 get max => _max;

 Aabb3() {
   _min = new Vector3.zero();
   _max = new Vector3.zero();
 }

 Aabb3.copy(Aabb3 other) {
   _min = new Vector3.copy(other._min);
   _max = new Vector3.copy(other._max);
 }

 Aabb3.minmax(Vector3 min_, Vector3 max_) {
   _min = new Vector3.copy(min_);
   _max = new Vector3.copy(max_);
 }

 void copyMinMax(Vector3 min_, Vector3 max_) {
   max_.setFrom(_max);
   min_.setFrom(_min);
 }

 void copyCenterAndHalfExtents(Vector3 center, Vector3 halfExtents) {
   center.setFrom(_min);
   center.add(_max);
   center.scale(0.5);
   halfExtents.setFrom(_max);
   halfExtents.sub(_min);
   halfExtents.scale(0.5);
 }

 void copyFrom(Aabb3 o) {
   _min.setFrom(o._min);
   _max.setFrom(o._max);
 }

 void copyInto(Aabb3 o) {
   o._min.setFrom(_min);
   o._max.setFrom(_max);
 }

 Aabb3 transform(Matrix4 T) {
   Vector3 center = new Vector3.zero();
   Vector3 halfExtents = new Vector3.zero();
   copyCenterAndHalfExtents(center, halfExtents);
   T.transform3(center);
   T.absoluteRotate(halfExtents);
   _min.setFrom(center);
   _max.setFrom(center);

   _min.sub(halfExtents);
   _max.add(halfExtents);
   return this;
 }

 Aabb3 rotate(Matrix4 T) {
   Vector3 center = new Vector3.zero();
   Vector3 halfExtents = new Vector3.zero();
   copyCenterAndHalfExtents(center, halfExtents);
   T.absoluteRotate(halfExtents);
   _min.setFrom(center);
   _max.setFrom(center);

   _min.sub(halfExtents);
   _max.add(halfExtents);
   return this;
 }

 Aabb3 transformed(Matrix4 T, Aabb3 out) {
   out.copyFrom(this);
   return out.transform(T);
 }

 Aabb3 rotated(Matrix4 T, Aabb3 out) {
   out.copyFrom(this);
   return out.rotate(T);
 }

 void getPN(Vector3 planeNormal, Vector3 outP, Vector3 outN) {
   outP.x = planeNormal.x < 0.0 ? _min.x : _max.x;
   outP.y = planeNormal.y < 0.0 ? _min.y : _max.y;
   outP.z = planeNormal.z < 0.0 ? _min.z : _max.z;

   outN.x = planeNormal.x < 0.0 ? _max.x : _min.x;
   outN.y = planeNormal.y < 0.0 ? _max.y : _min.y;
   outN.z = planeNormal.z < 0.0 ? _max.z : _min.z;
 }
}

Constructors

new Aabb3() #

Aabb3() {
 _min = new Vector3.zero();
 _max = new Vector3.zero();
}

new Aabb3.copy(Aabb3 other) #

Aabb3.copy(Aabb3 other) {
 _min = new Vector3.copy(other._min);
 _max = new Vector3.copy(other._max);
}

new Aabb3.minmax(Vector3 min_, Vector3 max_) #

Aabb3.minmax(Vector3 min_, Vector3 max_) {
 _min = new Vector3.copy(min_);
 _max = new Vector3.copy(max_);
}

Properties

final Vector3 max #

Vector3 get max => _max;

final Vector3 min #

Vector3 get min => _min;

Methods

void copyCenterAndHalfExtents(Vector3 center, Vector3 halfExtents) #

void copyCenterAndHalfExtents(Vector3 center, Vector3 halfExtents) {
 center.setFrom(_min);
 center.add(_max);
 center.scale(0.5);
 halfExtents.setFrom(_max);
 halfExtents.sub(_min);
 halfExtents.scale(0.5);
}

void copyFrom(Aabb3 o) #

void copyFrom(Aabb3 o) {
 _min.setFrom(o._min);
 _max.setFrom(o._max);
}

void copyInto(Aabb3 o) #

void copyInto(Aabb3 o) {
 o._min.setFrom(_min);
 o._max.setFrom(_max);
}

void copyMinMax(Vector3 min_, Vector3 max_) #

void copyMinMax(Vector3 min_, Vector3 max_) {
 max_.setFrom(_max);
 min_.setFrom(_min);
}

void getPN(Vector3 planeNormal, Vector3 outP, Vector3 outN) #

void getPN(Vector3 planeNormal, Vector3 outP, Vector3 outN) {
 outP.x = planeNormal.x < 0.0 ? _min.x : _max.x;
 outP.y = planeNormal.y < 0.0 ? _min.y : _max.y;
 outP.z = planeNormal.z < 0.0 ? _min.z : _max.z;

 outN.x = planeNormal.x < 0.0 ? _max.x : _min.x;
 outN.y = planeNormal.y < 0.0 ? _max.y : _min.y;
 outN.z = planeNormal.z < 0.0 ? _max.z : _min.z;
}

Aabb3 rotate(Matrix4 T) #

Aabb3 rotate(Matrix4 T) {
 Vector3 center = new Vector3.zero();
 Vector3 halfExtents = new Vector3.zero();
 copyCenterAndHalfExtents(center, halfExtents);
 T.absoluteRotate(halfExtents);
 _min.setFrom(center);
 _max.setFrom(center);

 _min.sub(halfExtents);
 _max.add(halfExtents);
 return this;
}

Aabb3 rotated(Matrix4 T, Aabb3 out) #

Aabb3 rotated(Matrix4 T, Aabb3 out) {
 out.copyFrom(this);
 return out.rotate(T);
}

Aabb3 transform(Matrix4 T) #

Aabb3 transform(Matrix4 T) {
 Vector3 center = new Vector3.zero();
 Vector3 halfExtents = new Vector3.zero();
 copyCenterAndHalfExtents(center, halfExtents);
 T.transform3(center);
 T.absoluteRotate(halfExtents);
 _min.setFrom(center);
 _max.setFrom(center);

 _min.sub(halfExtents);
 _max.add(halfExtents);
 return this;
}

Aabb3 transformed(Matrix4 T, Aabb3 out) #

Aabb3 transformed(Matrix4 T, Aabb3 out) {
 out.copyFrom(this);
 return out.transform(T);
}