/usr/share/doc/python-box2d-doc/testbed/test_StaticEdges.py is in python-box2d-doc 2.0.2+svn20100109.244-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | #!/usr/bin/python
#
# C++ version Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
# Python version Copyright (c) 2008 kne / sirkne at gmail dot com
#
# Implemented using the pybox2d SWIG interface for Box2D (pybox2d.googlecode.com)
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
from test_main import *
class StaticEdges (Framework):
name="StaticEdges"
def __init__(self):
super(StaticEdges, self).__init__()
sd1=box2d.b2CircleDef()
sd1.radius = 0.5
sd1.localPosition = (-0.5, 0.5)
sd1.density = 2.0
sd2=box2d.b2CircleDef()
sd2.radius = 0.5
sd2.localPosition = (0.5, 0.5)
sd2.density = 0.0 # massless
for i in range(10):
x = box2d.b2Random(-0.1, 0.1)
bd=box2d.b2BodyDef()
bd.position = (x + 5.0, 1.05 + 2.5 * i)
bd.angle = box2d.b2Random(-box2d.b2_pi, box2d.b2_pi)
body = self.world.CreateBody(bd)
body.CreateShape(sd1)
body.CreateShape(sd2)
body.SetMassFromShapes()
sd1=box2d.b2PolygonDef()
sd1.SetAsBox(0.25, 0.5)
sd1.density = 2.0
sd2=box2d.b2PolygonDef()
sd2.SetAsBox(0.25, 0.5, (0.0, -0.5), 0.5 * box2d.b2_pi)
sd2.density = 2.0
for i in range(10):
x = box2d.b2Random(-0.1, 0.1)
bd=box2d.b2BodyDef()
bd.position = (x - 5.0, 1.05 + 2.5 * i)
bd.angle = box2d.b2Random(-box2d.b2_pi, box2d.b2_pi)
body = self.world.CreateBody(bd)
body.CreateShape(sd1)
body.CreateShape(sd2)
body.SetMassFromShapes()
xf1=box2d.b2XForm()
xf1.R.Set(0.3524 * box2d.b2_pi)
xf1.position = box2d.b2Mul(xf1.R, (1.0, 0.0))
sd1=box2d.b2PolygonDef()
sd1.vertexCount = 3
sd1.setVertex(0, box2d.b2Mul(xf1, (-1.0, 0.0)))
sd1.setVertex(1, box2d.b2Mul(xf1, (1.0, 0.0)))
sd1.setVertex(2, box2d.b2Mul(xf1, (0.0, 0.5)))
sd1.density = 2.0
xf2=box2d.b2XForm()
xf2.R.Set(-0.3524 * box2d.b2_pi)
xf2.position = box2d.b2Mul(xf2.R, (-1.0, 0.0))
sd2=box2d.b2PolygonDef()
sd2.vertexCount = 3
sd2.setVertex(0, box2d.b2Mul(xf2, (-1.0, 0.0)))
sd2.setVertex(1, box2d.b2Mul(xf2, (1.0, 0.0)))
sd2.setVertex(2, box2d.b2Mul(xf2, (0.0, 0.5)))
sd2.density = 2.0
for i in range(10):
x = box2d.b2Random(-0.1, 0.1)
bd=box2d.b2BodyDef()
bd.position = (x, 2.05 + 2.5 * i)
bd.angle = 0.0
body = self.world.CreateBody(bd)
body.CreateShape(sd1)
body.CreateShape(sd2)
body.SetMassFromShapes()
loop1 = [
(0.063134534,8.3695248),
(0.94701801,9.3165428),
(0.0,9.0640047),
(-0.12626907,10.326695),
(1.4520943,11.77879),
(2.2728432,10.137292),
(2.3991123,11.147444),
(3.5986685,10.958041),
(3.9143411,7.3593722),
(4.1668793,9.4428119),
(5.4295699,9.3165428),
(6.2503189,8.3063903),
(6.6922606,10.137292),
(4.9876282,9.8216191),
(4.7350901,10.958041),
(7.2604714,11.652521),
(10.732871,11.147444),
(10.480333,10.642368),
(10.732871,9.8216191),
(11.55362,9.4428119),
(12.374369,9.3796773),
(13.005714,9.8216191),
(13.195118,10.38983),
(13.005714,10.768637),
(12.626907,10.894906),
(12.753176,11.526252),
(13.573925,11.715655),
(14.836616,11.399982),
(16.351844,10.768637),
(17.867073,11.399982),
(17.803939,10.263561),
(17.361997,8.3063903),
(17.803939,8.1801212),
(18.056477,9.5059464),
(18.182746,11.336848),
(18.561553,11.210579),
(18.561553,9.6322155),
(18.561553,7.7381795),
(18.687822,5.5284708),
(19.382302,5.6547398),
(19.066629,8.1801212),
(19.003495,10.263561),
(19.066629,11.463117),
(19.887378,11.841924),
(20.708127,11.273713),
(21.0238,10.011023),
(20.708127,7.2962377),
(21.086934,6.2860852),
(21.150069,3.7607038),
(20.392455,2.5611476),
(18.624688,2.5611476),
(20.771262,2.1192059),
(20.771262,0.22516988),
(18.624688,-0.2799064),
(13.826463,0.16203534),
(14.015867,1.7403987),
(13.195118,2.1823404),
(12.626907,1.5509951),
(12.879445,0.85651522),
(12.626907,0.35143895),
(10.543467,1.298457),
(11.490485,3.9501074),
(13.889598,3.6344347),
(13.889598,2.9399549),
(14.584077,3.8869729),
(11.932427,5.2127981),
(9.7227183,4.0132419),
(10.796005,3.5081657),
(9.7858528,3.2556275),
(10.796005,2.4980131),
(7.9549513,1.7403987),
(9.6595837,1.424726),
(9.217642,0.66711162),
(8.270624,-0.090502792),
(7.0079333,0.85651522),
(6.1240498,-0.15363733),
(6.1240498,3.192493),
(5.6821081,2.4348786),
(4.9876282,2.1192059),
(4.1037447,1.8666678),
(3.0304576,1.8666678),
(2.0834396,2.245475),
(1.6414979,2.6242822),
(1.3258252,3.5081657),
(1.2626907,0.47770802),
(0.63134534,0.035766276),
(0.063134534,0.9827842),
]
loop2 = [
(8.270624,6.1598161),
(8.270624,5.3390672),
(8.7757003,5.086529),
(9.4701801,5.5284708),
(9.217642,6.033547),
(8.7757003,6.412354),
]
b2Loop1 = [(loop[0] - 10.0, loop[1]) for loop in loop1]
b2Loop2 = [(loop[0] - 10.0, loop[1]) for loop in loop2]
bd=box2d.b2BodyDef()
bd.position = ( 0.0, 0.0 )
body = self.world.CreateBody(bd)
edgeDef=box2d.b2EdgeChainDef()
edgeDef.vertices=b2Loop1
body.CreateShape(edgeDef)
edgeDef.vertices=b2Loop2
body.CreateShape(edgeDef)
#body.SetMassFromShapes()
if __name__=="__main__":
main(StaticEdges)
|