Esempio n. 1
0
def angle_between_vectors(veca: Vector, vecb: Vector):
    unta = veca.to_unit()
    untb = vecb.to_unit()
    adb = unta * untb
    if adb > 1.0:
        adb = 1.0
    elif adb < -1.0:
        adb = -1.0
    return acos(adb)
Esempio n. 2
0
 def __init__(self,
              grda: Vector,
              grdb: Vector,
              diro: Vector,
              ind: int = None):
     self.grda = grda
     self.grdb = grdb
     self.diro = diro.to_unit()
     self.ind = ind
Esempio n. 3
0
 def doublet_influence_coefficients(self,
                                    pnts: MatrixVector,
                                    incvel: bool = True,
                                    betx: float = 1.0,
                                    bety: float = 1.0,
                                    betz: float = 1.0,
                                    checktol: bool = False):
     vecab = Vector(self.vecab.x / betx, self.vecab.y / bety,
                    self.vecab.z / betz)
     dirxab = vecab.to_unit()
     dirzab = Vector(self.nrm.x, self.nrm.y, self.nrm.z)
     diryab = dirzab**dirxab
     agcs = self.relative_mach(pnts,
                               self.grda,
                               betx=betx,
                               bety=bety,
                               betz=betz)
     bgcs = self.relative_mach(pnts,
                               self.grdb,
                               betx=betx,
                               bety=bety,
                               betz=betz)
     locz = agcs * self.nrm
     sgnz = ones(locz.shape, dtype=float)
     sgnz[locz <= 0.0] = -1.0
     phid = zeros(pnts.shape, dtype=float)
     if incvel:
         veld = zero_matrix_vector(pnts.shape, dtype=float)
     # Vector A in Local Coordinate System
     alcs = MatrixVector(agcs * dirxab, agcs * diryab, agcs * dirzab)
     if checktol:
         alcs.x[absolute(alcs.x) < tol] = 0.0
         alcs.y[absolute(alcs.y) < tol] = 0.0
         alcs.z[absolute(alcs.z) < tol] = 0.0
     # Vector A Doublet Velocity Potentials
     phida, amag = phi_doublet_matrix(alcs, sgnz)
     # Vector B in Local Coordinate System
     blcs = MatrixVector(bgcs * dirxab, bgcs * diryab, bgcs * dirzab)
     if checktol:
         blcs.x[absolute(blcs.x) < tol] = 0.0
         blcs.y[absolute(blcs.y) < tol] = 0.0
         blcs.z[absolute(blcs.z) < tol] = 0.0
     # Vector B Doublet Velocity Potentials
     phidb, bmag = phi_doublet_matrix(blcs, sgnz)
     # Edge Doublet Velocity Potentials
     phidi = phida - phidb
     # Add Edge Velocity Potentials
     phid += phidi
     if incvel:
         # Bound Edge Velocities in Local Coordinate System
         veldi = vel_doublet_matrix(alcs, amag, blcs, bmag)
         # Transform to Global Coordinate System and Add
         dirxi = Vector(dirxab.x, diryab.x, dirzab.x)
         diryi = Vector(dirxab.y, diryab.y, dirzab.y)
         dirzi = Vector(dirxab.z, diryab.z, dirzab.z)
         veld += MatrixVector(veldi * dirxi, veldi * diryi, veldi * dirzi)
     # Trailing Edge A Coordinate Transformation
     dirxa = self.diro
     dirza = self.nrm
     dirya = -dirza**dirxa
     alcs = MatrixVector(agcs * dirxa, agcs * dirya, agcs * dirza)
     # Trailing Edge A Velocity Potential
     phida, amag = phi_doublet_matrix(alcs, sgnz)
     phidt = phi_trailing_doublet_matrix(alcs, sgnz)
     phidi = phida + phidt
     # Add Trailing Edge A Velocity Potentials
     phid += phidi
     # Trailing Edge B Coordinate Transformation
     if incvel:
         # Trailing Edge A Velocities in Local Coordinate System
         veldi = vel_trailing_doublet_matrix(alcs, amag, 1.0)
         # Transform to Global Coordinate System and Add
         dirxi = Vector(dirxa.x, dirya.x, dirza.x)
         diryi = Vector(dirxa.y, dirya.y, dirza.y)
         dirzi = Vector(dirxa.z, dirya.z, dirza.z)
         veld += MatrixVector(veldi * dirxi, veldi * diryi, veldi * dirzi)
     # Trailing Edge B Coordinate Transformation
     dirxb = self.diro
     dirzb = self.nrm
     diryb = dirzb**dirxb
     blcs = MatrixVector(bgcs * dirxb, bgcs * diryb, bgcs * dirzb)
     # Trailing Edge B Velocity Potential
     phidb, bmag = phi_doublet_matrix(blcs, sgnz)
     phidt = phi_trailing_doublet_matrix(blcs, sgnz)
     phidi = phidb + phidt
     # Add Trailing Edge B Velocity Potentials
     phid += phidi
     if incvel:
         # Trailing Edge B Velocities in Local Coordinate System
         veldi = vel_trailing_doublet_matrix(blcs, bmag, 1.0)
         # Transform to Global Coordinate System and Add
         dirxi = Vector(dirxb.x, diryb.x, dirzb.x)
         diryi = Vector(dirxb.y, diryb.y, dirzb.y)
         dirzi = Vector(dirxb.z, diryb.z, dirzb.z)
         veld += MatrixVector(veldi * dirxi, veldi * diryi, veldi * dirzi)
     # Factors and Outputs
     phid = phid / fourPi
     if incvel:
         veld = veld / fourPi
         output = phid, veld
     else:
         output = phid
     return output
Esempio n. 4
0
 def __init__(self, pnto: Vector, grdo: Vector, diro: Vector, faco: float):
     self.pnto = pnto
     self.grdo = grdo
     self.diro = diro.to_unit()
     self.faco = faco / abs(faco)
Esempio n. 5
0
 def set_hinge_vector(self, hvec: Vector):
     if hvec.return_magnitude() != 0.0:
         self.uhvec = hvec.to_unit()
     else:
         self.uhvec = hvec