Changeset 663
- Timestamp:
- 08/19/03 11:38:47 (5 years ago)
- Files:
-
- trunk/RBRapier/RBRapier/Tools/Geometry/Curves.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/RBRapier/RBRapier/Tools/Geometry/Curves.py
r662 r663 155 155 156 156 157 def fromArc(klass, fromxy, toxy, rx=1., ry=1., xrotation=0, large arcflag=False, sweepflag=False, inDegrees=True, **kw):157 def fromArc(klass, fromxy, toxy, rx=1., ry=1., xrotation=0, largeArcFlag=False, sweepFlag=False, inDegrees=True, **kw): 158 158 """ 159 159 Derived from SVG Specification: … … 165 165 toxy = Numeric.asarray(toxy, klass.NumericType) 166 166 if xrotation: 167 x, y = Numeric.dot(klass._RotationMatrix( xrotation), 0.5*(fromxy-toxy))167 x, y = Numeric.dot(klass._RotationMatrix(-xrotation), 0.5*(fromxy-toxy)) 168 168 else: 169 169 x, y = 0.5*(fromxy-toxy) 170 x2 = x**2 171 y2 = y**2 172 173 rx2 = rx**2 174 ry2 = ry**2 170 x2,y2 = x**2, y**2 171 172 rx2, ry2 = rx**2, ry**2 175 173 radiscale = x2/rx2 + y2/ry2 176 174 if radiscale > 1: 177 175 # ellipse is not big enough... scale it 178 176 radiscale = Numeric.sqrt(radiscale) 179 rx *= radiscale 180 ry *= radiscale 181 rx2 = rx**2 182 ry2 = ry**2 177 rx, ry = radiscale*rx, radiscale*ry 178 rx2, ry2 = rx**2, ry**2 183 179 184 180 tmp = rx2*y2 + ry2*x2 185 sign = (large arcflag ^ sweepflag) and 1 or -1181 sign = (largeArcFlag != sweepFlag) and 1 or -1 186 182 scale = sign * Numeric.sqrt((rx2*ry2-tmp)/tmp) 187 188 cxP, cyP = scale*rx*y/ry, -scale*ry*x/rx 183 cxP, cyP = scale*rx*y/ry, scale*-ry*x/rx 184 189 185 if xrotation: 190 186 rot = klass._RotTranMatrix(xrotation, (0.5*(fromxy+toxy))) 191 center = Numeric.dot(rot, Numeric.asarray([cxP, cyP, 1.], klass.NumericType)) [:2]192 center2 = Numeric.asarray([cxP, cyP]) + (0.5*(fromxy+toxy))193 else:194 center = Numeric.asarray([cxP, cyP]) + (0.5*(fromxy+toxy))[:2]187 center = Numeric.dot(rot, Numeric.asarray([cxP, cyP, 1.], klass.NumericType)) 188 else: 189 center = Numeric.asarray([cxP, cyP]) + (0.5*(fromxy+toxy)) 190 center = center[:2] 195 191 196 192 startpt = ((x-cxP)/rx, (y-cyP)/ry) 197 193 endpt = ((-x-cxP)/rx, (-y-cyP)/ry) 198 194 startradians = klass._FindAngle((1., 0.), startpt) 199 sweepradians = klass._FindAngle(startpt, endpt) 200 if sweep flag:195 sweepradians = klass._FindAngle(startpt, endpt) % _2pi 196 if sweepFlag: 201 197 if sweepradians < 0: 202 198 sweepradians += _2pi … … 246 242 return Numeric.transpose(ellipse[:-1,:]) 247 243 else: 248 ellipse = Numeric.asarray([rx*Numeric.cos(sweep), ry*Numeric.sin(sweep)], self.NumericType) 244 cx, cy = self.GetCenter() 245 ellipse = Numeric.asarray([rx*Numeric.cos(sweep)+cx, ry*Numeric.sin(sweep)+cy], self.NumericType) 249 246 return Numeric.transpose(ellipse) 250 247 … … 259 256 260 257 def _RotationMatrix(klass, radians): 258 """Count clockwise rotation""" 261 259 cosr = Numeric.cos(radians) 262 260 sinr = Numeric.sin(radians) 263 return Numeric.asarray([[cosr, sinr],[-sinr, cosr]], klass.NumericType)261 return Numeric.asarray([[cosr, -sinr],[sinr, cosr]], klass.NumericType) 264 262 _RotationMatrix = classmethod(_RotationMatrix) 265 263 266 264 def _RotTranMatrix(klass, radians, (tx, ty)=(0.,0.)): 265 """Count clockwise rotation""" 267 266 cosr = Numeric.cos(radians) 268 267 sinr = Numeric.sin(radians) 269 return Numeric.asarray([[cosr, sinr, tx],[-sinr, cosr, ty], [0., 0., 1.]], klass.NumericType)268 return Numeric.asarray([[cosr, -sinr, tx],[sinr, cosr, ty], [0., 0., 1.]], klass.NumericType) 270 269 _RotTranMatrix = classmethod(_RotTranMatrix) 271 270
