This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Very simple way to compute the center (centroid) of a triangle. | |
// The only things you have to know are the three vectors forming the triangle. | |
// vector = [x, y, z]; | |
var vectorA = [-1, -3, -2]; | |
var vectorB = [2, 1, 2]; | |
var vectorC = [8, -4, 1]; | |
var centerX = ((vectorA[0] + vectorB[0] + vectorC[0]) / 3); | |
var centerY = ((vectorA[1] + vectorB[1] + vectorC[1]) / 3); |