blob: 23b43fcd90717d1534f9d4c24764ecbad5852875 [file] [log] [blame]
// Copyright (c) 2015, Google Inc. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
part of vector_math_64;
/// Defines a triangle by three points.
class Triangle {
final Vector3 _point0;
final Vector3 _point1;
final Vector3 _point2;
/// The first point of the triangle.
Vector3 get point0 => _point0;
/// The second point of the triangle.
Vector3 get point1 => _point1;
/// The third point of the triangle.
Vector3 get point2 => _point2;
/// Create a new, uninitialized triangle.
: _point0 =,
_point1 =,
_point2 =;
/// Create a triangle as a copy of [other].
Triangle.copy(Triangle other)
: _point0 = Vector3.copy(other._point0),
_point1 = Vector3.copy(other._point1),
_point2 = Vector3.copy(other._point2);
/// Create a triangle by three points.
Triangle.points(Vector3 point0, Vector3 point1, Vector3 point2)
: _point0 = Vector3.copy(point0),
_point1 = Vector3.copy(point1),
_point2 = Vector3.copy(point2);
/// Copy the triangle from [other] into this.
void copyFrom(Triangle other) {
/// Copy the normal of this into [normal].
void copyNormalInto(Vector3 normal) {
final v0 = point0.clone()..sub(point1);
..crossInto(v0, normal)
/// Transform this by the transform [t].
void transform(Matrix4 t) {
/// Translate this by [offset].
void translate(Vector3 offset) {