示例#1
0
文件: geom.go 项目: amsibamsi/three
// Transf transforms a 3D triangle with the given transformation matrix and
// returns a 2D triangle.
func (t *Tri4) Transf(m *geom.Mat4) *Tri2 {
	p1 := m.Transf(&t[0])
	x1 := tmath.Round(p1[0] / p1[3])
	y1 := tmath.Round(p1[1] / p1[3])
	p2 := m.Transf(&t[1])
	x2 := tmath.Round(p2[0] / p2[3])
	y2 := tmath.Round(p2[1] / p2[3])
	p3 := m.Transf(&t[2])
	x3 := tmath.Round(p3[0] / p3[3])
	y3 := tmath.Round(p3[1] / p3[3])
	return NewTri2(x1, y1, x2, y2, x3, y3)
}