Exemplo n.º 1
0
func MomentForPoly(mass float64, verts []Vect, offset Vect) float64 {
	cpverts := make([]C.cpVect, 0)
	for _, vert := range verts {
		cpverts = append(cpverts, vert.CPVect)
	}
	return float64(C.cpMomentForPoly(C.cpFloat(mass), C.int(len(verts)), &cpverts[0], offset.CPVect))
}
Exemplo n.º 2
0
// MomentForPoly returns the moment of inertia for a solid polygon shape assuming
// it's center of gravity is at it's centroid. The offset is added to each vertex.
func MomentForPoly(m float64, verts []Vect, offset Vect) float64 {
	v := (*C.cpVect)(unsafe.Pointer(&verts[0]))
	return float64(C.cpMomentForPoly(C.cpFloat(m), C.int(len(verts)), v, offset.c()))
}