Пример #1
0
 def __init__(self, mean, stddev):
     mean = type_support.toScalar(mean,
                                  f'Normal mean {mean} is not a scalar')
     stddev = type_support.toScalar(
         stddev, f'Normal stddev {stddev} is not a scalar')
     super().__init__(mean, stddev, valueType=float)
     self.mean = mean
     self.stddev = stddev
Пример #2
0
 def __init__(self, low, high):
     low = type_support.toScalar(low,
                                 f'Range endpoint {low} is not a scalar')
     high = type_support.toScalar(high,
                                  f'Range endpoint {high} is not a scalar')
     super().__init__(low, high, valueType=float)
     self.low = low
     self.high = high
Пример #3
0
def Follow(F, X, D):
	if not isinstance(F, VectorField):
		raise RuntimeParseError('"follow F from X for D" with F not a vector field')
	X = toVector(X, '"follow F from X for D" with X not a vector')
	D = toScalar(D, '"follow F from X for D" with D not a number')
	pos = F.followFrom(X, D)
	heading = F[pos]
	return OrientedPoint(position=pos, heading=heading)
Пример #4
0
def Following(field, dist, fromPt=None):
	"""The 'following F [from X] for D' specifier.

	Specifies 'position', and optionally 'heading', with no dependencies.

	Allowed forms:
		following <field> [from <vector>] for <number>

	If the 'from <vector>' is omitted, the position of ego is used.
	"""
	if fromPt is None:
		fromPt = ego()
	else:
		dist, fromPt = fromPt, dist
	if not isinstance(field, VectorField):
		raise RuntimeParseError('"following F" specifier with F not a vector field')
	fromPt = toVector(fromPt, '"following F from X for D" with X not a vector')
	dist = toScalar(dist, '"following F for D" with D not a number')
	pos = field.followFrom(fromPt, dist)
	heading = field[pos]
	val = OrientedVector.make(pos, heading)
	return Specifier('position', val, optionals={'heading'})
Пример #5
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.heading = toScalar(self.heading,
                             f'"heading" of {self} not a scalar')
     self.visibleRegion = SectorRegion(self.position, self.visibleDistance,
                                       self.heading, self.viewAngle)
Пример #6
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.heading = toScalar(self.heading,
                             f'"heading" of {self} not a scalar')