Golang C.cpFloat类(方法)实例源码

下面列出了Golang C.cpFloat 类(方法)源码代码实例,从而了解它的用法。

作者:ftrvxmtr    项目:gochipmun   
// c converts BB to C.cpBB.
func (b BB) c() C.cpBB {
	return C.cpBB{
		l: C.cpFloat(b.l),
		b: C.cpFloat(b.b),
		r: C.cpFloat(b.r),
		t: C.cpFloat(b.t)}
}

作者:ianremmle    项目:chipmun   
// DampedSpringNew creates a new damped spring.
func DampedSpringNew(a, b Body, anchr1, anchr2 Vect,
	restLength, stiffness, damping float64) DampedSpring {

	c := C.cpDampedSpringNew(a.c(), b.c(), anchr1.c(), anchr2.c(), C.cpFloat(restLength),
		C.cpFloat(stiffness), C.cpFloat(damping))

	return DampedSpring{cpConstraintBaseNew(c)}
}

作者:ftrvxmtr    项目:gochipmun   
// DampedRotarySpringNew creates a new damped rotary spring.
func DampedRotarySpringNew(a, b Body, restAngle, stiffness, damping float64) DampedRotarySpring {
	c := C.cpDampedRotarySpringNew(
		a.c(),
		b.c(),
		C.cpFloat(restAngle),
		C.cpFloat(stiffness),
		C.cpFloat(damping))

	return DampedRotarySpring{cpconstraint_new(c)}
}

作者:paulcoyl    项目:gochipmun   
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))
}

作者:ftrvxmtr    项目:gochipmun   
// ConvexHull calculates the convex hull of a given set of points.
// Returns the points and index of the first vertex in the hull came from the input.
// Tolerance is the allowed amount to shrink the hull when simplifying it.
// A tolerance of 0.0 creates an exact hull.
func ConvexHull(verts []Vect, tolerance float64) ([]Vect, int) {
	result := make([]Vect, len(verts))
	var first C.int
	v := (*C.cpVect)(unsafe.Pointer(&verts[0]))
	r := (*C.cpVect)(unsafe.Pointer(&result[0]))
	num := int(C.cpConvexHull(C.int(len(verts)), v, r, &first, C.cpFloat(tolerance)))
	final := make([]Vect, num, num)
	copy(final, result[:num])
	return final, int(first)
}

作者:paulcoyl    项目:gochipmun   
func (v *Vect) WrapToBounds(ax float64, ay float64, bx float64, by float64) {
	x, y := float64(v.CPVect.x), float64(v.CPVect.y)
	w, h := bx-ax, by-ay

	if x < ax {
		x += w
	} else if x >= bx {
		x -= w
	}

	if y < ay {
		y += h
	} else if y >= by {
		y -= h
	}

	v.CPVect.x = C.cpFloat(x)
	v.CPVect.y = C.cpFloat(y)
}

作者:ianremmle    项目:chipmun   
// SetContactPoints replaces the contact point set for an arbiter.
// This can be a very powerful feature, but use it with caution!
func (a Arbiter) SetContactPoints(cp []ContactPoint) {
	if len(cp) > C.CP_MAX_CONTACTS_PER_ARBITER {
		cp = cp[:C.CP_MAX_CONTACTS_PER_ARBITER]
	}
	set := &C.cpContactPointSet{count: C.int(len(cp))}
	for i := range cp {
		set.points[i].point = cp[i].Point.c()
		set.points[i].normal = cp[i].Normal.c()
		set.points[i].dist = C.cpFloat(cp[i].Dist)
	}
	C.cpArbiterSetContactPointSet(a.c(), set)
}

作者:ftrvxmtr    项目:gochipmun   
// NearestPointQuery queries the space at a point and calls a callback function for each shape found.
func (s *Space) NearestPointQuery(
	point Vect,
	maxDistance float64,
	layers Layers,
	group Group,
	f NearestPointQuery) {
	C.space_nearest_point_query(
		s.c(),
		point.c(),
		C.cpFloat(maxDistance),
		layers.c(),
		group.c(),
		Pointer(&f))
}

作者:paulcoyl    项目:gochipmun   
func (b *Body) SetVelocityLimit(limit float64) {
	b.CPBody.v_limit = C.cpFloat(limit)
}

作者:paulcoyl    项目:gochipmun   
func NewBody(mass float64, moment float64) *Body {
	var cpbody *C.cpBody = C.cpBodyNew(C.cpFloat(mass), C.cpFloat(moment))
	body := Body{cpbody}
	bodyLookup[cpbody] = &body
	return &body
}

作者:paulcoyl    项目:gochipmun   
func (b *Body) SetAngle(angle float64) {
	C.cpBodySetAngle(b.CPBody, C.cpFloat(angle))
}

作者:ftrvxmtr    项目:gochipmun   
// Step makes the space step forward in time by dt seconds.
func (s *Space) Step(dt float64) {
	C.cpSpaceStep(s.c(), C.cpFloat(dt))
}

作者:ftrvxmtr    项目:gochipmun   
// UseSpatialHash switches the space to use a spatial has as it's spatial index.
func (s *Space) UseSpatialHash(dim float64, count int) {
	C.cpSpaceUseSpatialHash(s.c(), C.cpFloat(dim), C.int(count))
}

作者:paulcoyl    项目:gochipmun   
func (s *Shape) SetFriction(friction float64) {
	s.CPShape.u = C.cpFloat(friction)
}

作者:ftrvxmtr    项目:gochipmun   
// SetSleepTimeThreshold sets the time a group of bodies must remain idle in order to fall asleep.
// Enabling sleeping also implicitly enables the the contact graph.
// The default value of math.Inf(1) disables the sleeping algorithm.
func (s *Space) SetSleepTimeThreshold(t float64) {
	C.cpSpaceSetSleepTimeThreshold(s.c(), C.cpFloat(t))
}

作者:paulcoyl    项目:gochipmun   
func NewBoundingBox(l float64, b float64, r float64, t float64) *BoundingBox {
	cpbb := C.cpBBNew(C.cpFloat(l), C.cpFloat(b), C.cpFloat(r), C.cpFloat(t))
	boundingbox := BoundingBox{cpbb}
	return &boundingbox
}

作者:ianremmle    项目:chipmun   
// SetRestLength sets the length the spring wants to contract or expand to.
func (c DampedSpring) SetRestLength(restLength float64) {
	C.cpDampedSpringSetRestLength(c.c(), C.cpFloat(restLength))
}

作者:ftrvxmtr    项目:gochipmun   
// SetMaxBias sets the maximum rate (speed) that a joint can be corrected at (defaults to infinity).
func (c constraintBase) SetMaxBias(b float64) {
	C.cpConstraintSetMaxBias(c.c(), C.cpFloat(b))
}

作者:paulcoyl    项目:gochipmun   
func (b *Body) SetAngularRotation(omega float64) {
	b.CPBody.w = C.cpFloat(omega)
}

作者:ianremmle    项目:chipmun   
// SetRestAngle sets the angular offset in radians the spring attempts to keep between the two bodies.
func (c DampedRotarySpring) SetRestAngle(restAngle float64) {
	C.cpDampedRotarySpringSetRestAngle(c.c(), C.cpFloat(restAngle))
}


问题


面经


文章

微信
公众号

扫码关注公众号