本文整理汇总了Golang中C.cpFloat函数的典型用法代码示例。如果您正苦于以下问题:Golang cpFloat函数的具体用法?Golang cpFloat怎么用?Golang cpFloat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cpFloat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: c
// 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)}
}
示例2: DampedSpringNew
// 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)}
}
示例3: DampedRotarySpringNew
// 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)}
}
示例4: MomentForPoly
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))
}
示例5: ConvexHull
// 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)
}
示例6: WrapToBounds
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)
}
示例7: SetContactPoints
// 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)
}
示例8: NearestPointQuery
// 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))
}
示例9: SetVelocityLimit
func (b *Body) SetVelocityLimit(limit float64) {
b.CPBody.v_limit = C.cpFloat(limit)
}
示例10: NewBody
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
}
示例11: SetAngle
func (b *Body) SetAngle(angle float64) {
C.cpBodySetAngle(b.CPBody, C.cpFloat(angle))
}
示例12: Step
// Step makes the space step forward in time by dt seconds.
func (s *Space) Step(dt float64) {
C.cpSpaceStep(s.c(), C.cpFloat(dt))
}
示例13: UseSpatialHash
// 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))
}
示例14: SetFriction
func (s *Shape) SetFriction(friction float64) {
s.CPShape.u = C.cpFloat(friction)
}
示例15: SetSleepTimeThreshold
// 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))
}