def does_contain( self, point ): '''Checks whether the 'point' (in geographic lon-lat terms) is inside the polygon. Uses 2D vector multiplication and comparing the result with zero. ''' # calculate point in local coords P = mathutils.Vector( geocoords.xyz_geographic( *point ) ) q = mathutils.Quaternion( self.q ) qc = q.conjugated() R = qc.to_matrix() p = R * P pv = mV( p ) l = len( self.verts_xyz_loc ) # make edges list EL = [ mV( self.verts_xyz_loc[ (i + 1) % l ] ) - mV( self.verts_xyz_loc[ i ] ) for i in range( l ) ] # checking cross prod sign - if all are positive - must be inside for i in range( len( self.verts_xyz_loc ) ): if cross2d( EL[i], pv - mV( self.verts_xyz_loc[i] ) ) < 0: return False return True
def lonlati_to_xyzi( verts ): '''Converts a list of (lon, lat, i) vertices into a list of (x, y, z, i) vertices, where 'i' is a silent index ''' cverts = [] for v in verts : t = list( geocoords.xyz_geographic( v[0], v[1] ) ) t.append( v[-1] ) cverts.append( t ) return cverts
def make_cartesian_( self ): '''Generetes inner data in Cartesian coords creates two 1D arrays for (uwnd, vwnd) and (x, y, z) tuples ''' if not self.vec: raise RuntimeError('no wind data assigned') self.cart_coords = [] for la in range(len(self.lat)): for lo in range(len(self.lon)): self.cart_coords.append( \ geocoords.xyz_geographic(self.lon[lo],self.lat[la])) self.cart_vec.append(self.vec[la][lo]) return
def lonlat_to_xyz( verts ): '''Converts a list of (lon, lat) vertices into a list of (x, y, z) vertices ''' cverts = [ geocoords.xyz_geographic( v[0], v[1] ) for v in verts ] return cverts