[Bf-python] Geometry Data
Campbell Barton
cbarton at metavr.com
Mon Jul 31 03:47:21 CEST 2006
Hi Guys,
Iv been thinking about having more abstract geometry data types.
I posted this before but here are some more details,
First, Id like to impliment a vector array type - basicly an iterator
that provides wrapped vector access to a C array. it would have the same
malloc problems ans Mesh but youd just need to define the size to begin
with.
once you had this data you could operate on it as a blob, apart from
being faster it would be easier to read and reuire a lot less looping in
python.
va= Geometry.VectorArray(200, 3) # 3d vec init as (0,0,0) 200 items
or it could be initialized from a a list of vectors
va=Geometry.VectorArray(me.verts)
now you could transform it just like a mesh
va.transform(matrix)
or get the bounds (annoying to do in Python)
bounds=va.bounds() # possibly have a function to intersect bounds also
Other functions could be
.removeDoubles() # remove points
.convexHull() # return indicies
.nearest(someVec) # finds the closest point to a vector
if Vector in VectorArray # would search for the point in the array.
It could also be used to define a poly line 2d or 3d
va_poly2d.area() #area of the poly
va_poly2d.PolyPoint(pt) #is the point inside the 2d poly
va_poly2d.PolySelfIntersec(pt) # does the poly intersect its self
va_poly2d.PolyIntersectPoly(poly2d)
and of course the existing poly fill ;)
I think this could also save memory too- how much memory does a BPy
vector take up by its self?
Theeth, respect your opinion (that this isnt a bottlenack) but Id like
to prove myself wrong before assuming these functions would not be much
faster in C /python
also depends on the scripts you write I suppose.
I could make some tests and use a Mesh as an example of a python array
(pretend of course) - then compare with a list of vectors.
Maybe we should look an numarray first?
Pygame had some examples of pixel operations in in numarray - Realtime
image distortion, that you could no way do in Python, so I think there
may be a use for this.
--
Campbell J Barton
133 Hope Street
Geelong West, Victoria 3218 Australia
URL: http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241
More information about the Bf-python
mailing list