当前位置: 首页>>代码示例>>Python>>正文


Python Quaternion.normalize方法代码示例

本文整理汇总了Python中Quaternion.normalize方法的典型用法代码示例。如果您正苦于以下问题:Python Quaternion.normalize方法的具体用法?Python Quaternion.normalize怎么用?Python Quaternion.normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Quaternion的用法示例。


在下文中一共展示了Quaternion.normalize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: calc_vis_values

# 需要导入模块: import Quaternion [as 别名]
# 或者: from Quaternion import normalize [as 别名]
def calc_vis_values(iproc, ephem_Times, chandra_ecis, q1s, q2s, q3s, q4s):
    outvals = []
    for t, chandra_eci, q1, q2, q3, q4 in zip(ephem_Times, chandra_ecis, q1s, q2s, q3s, q4s):
        alt = np.sqrt(np.sum(chandra_eci**2))/1e3
        date = re.sub(r'\.000$', '', DateTime(t).date)
        q_att = Quaternion.normalize([q1,q2,q3,q4])
        vis, illum, rays = taco.calc_earth_vis(chandra_eci, q_att, ngrid=opt.ngrid)
        title = '%s alt=%6.0f illum=%6.4f' % (date, alt, illum)
        outvals.append((t, illum, alt, q1, q2, q3, q4))
        if opt.verbose:
            print title, taco.norm(chandra_eci), q1, q2, q3, q4
        elif iproc == 0:
            print 'Progress: %d%%\r' % int((100. * len(outvals)) / len(ephem_Times) + 0.5),
            sys.stdout.flush()
开发者ID:sot,项目名称:taco,代码行数:16,代码来源:test_acis_rad_illum.py

示例2: euler2q

# 需要导入模块: import Quaternion [as 别名]
# 或者: from Quaternion import normalize [as 别名]
def euler2q(rx0, ry0, rz0):
    rx = rx0 * (np.pi / 180) / 2
    ry = ry0 * (np.pi / 180) / 2
    rz = rz0 * (np.pi / 180) / 2
    cz = np.cos(rz)
    sz = np.sin(rz)
    cy = np.cos(ry)
    sy = np.sin(ry)
    cx = np.cos(rx)
    sx = np.sin(rx)
    x = sx * cy * cz - cx * sy * sz
    y = cx * sy * cz + sx * cy * sz
    z = cx * cy * sz - sx * sy * cz
    w = cx * cy * cz + sx * sy * sz
    return Q.Quat(Q.normalize([x, y, z, w])).q
开发者ID:hyolee,项目名称:pose_experiments,代码行数:17,代码来源:generate_data_leaveout.py

示例3: make_pcad_attitude_check_report

# 需要导入模块: import Quaternion [as 别名]
# 或者: from Quaternion import normalize [as 别名]
def make_pcad_attitude_check_report(backstop_file, or_list_file=None, attitude_file=None,
                                    simtrans_file=None, simfocus_file=None,
                                    ofls_characteristics_file=None, out=None,
                                    dynamic_offsets_file=None,
                                    ):
    """
    Make a report for checking PCAD attitudes

    """
    all_ok = True
    lines = []  # output report lines

    bs = read_backstop(backstop_file)

    # Get initial state attitude and sim position from history
    att_time, q1, q2, q3, q4 = recent_attitude_history(DateTime(bs[0]['date']).secs,
                                            attitude_file)
    q = Quaternion.normalize([q1, q2, q3, q4])
    simfa_time, simfa = recent_sim_history(DateTime(bs[0]['date']).secs,
                                           simfocus_file)
    simpos_time, simpos = recent_sim_history(DateTime(bs[0]['date']).secs,
                                             simtrans_file)

    initial_state = {'q1': q[0],
                     'q2': q[1],
                     'q3': q[2],
                     'q4': q[3],
                     'simpos': simpos,
                     'simfa_pos': simfa}

    or_list = None if or_list_file is None else read_or_list(or_list_file)
    if or_list is None:
        lines.append('ERROR: No OR list provided, cannot check attitudes')
        all_ok = False

    # If dynamical offsets file is available then load was planned using
    # Matlab tools 2016_210 later, which implements the "Cycle 18 aimpoint
    # transition plan".  This code injects new OR list attributes for the
    # dynamical offset.
    if dynamic_offsets_file is not None and or_list is not None:
        # Existing OFLS characteristics file is not relevant for post 2016_210.
        # Products are planned using the Matlab tools SI align which matches the
        # baseline mission align matrix from pre-November 2015.
        ofls_characteristics_file = None

        lines.append('INFO: using dynamic offsets file {}'.format(dynamic_offsets_file))
        or_map = {or_['obsid']: or_ for or_ in or_list}

        doffs = Table.read(dynamic_offsets_file, format='ascii.basic', guess=False)
        for doff in doffs:
            obsid = doff['obsid']
            if obsid in or_map:
                or_map[obsid]['aca_offset_y'] = doff['aca_offset_y'] / 3600.
                or_map[obsid]['aca_offset_z'] = doff['aca_offset_z'] / 3600.

        # Check that obsids in dynamic offsets table are all in OR list
        if not set(doffs['obsid']).issubset(set(or_map)):
            all_ok = False
            obsid_mismatch = set(doffs['obsid']) - set(or_map)
            lines.append('WARNING: Obsid in dynamic offsets table but missing in OR list {}'
                         .format(list(obsid_mismatch)))

    # Run the commands and populate attributes in `sc`, the spacecraft state.
    # In particular sc.checks is a dict of checks by obsid.
    # Any state value (e.g. obsid or q_att) has a corresponding plural that
    # gives the history of updates as a dict with a `value` and `date` key.
    sc = hopper.run_cmds(backstop_file, or_list, ofls_characteristics_file,
                         initial_state=initial_state, starcheck=True)
    # Iterate through checks by obsid to print status
    checks = sc.get_checks_by_obsid()
    for obsid in sc.obsids:
        for check in checks[obsid]:
            if check.name == 'attitude_consistent_with_obsreq':
                ok = check.success
                all_ok &= ok
                if check.not_applicable:
                    message = 'SKIPPED: {}'.format(":".join(check.infos))
                else:
                    message = 'OK' if ok else "ERROR: {}".format(":".join(check.errors))
                    line = '{:5d}: {}'.format(obsid, message)
                lines.append(line)

    if out is not None:
        with open(out, 'w') as fh:
            fh.writelines("\n".join(lines))

    return all_ok
开发者ID:sot,项目名称:starcheck,代码行数:89,代码来源:pcad_att_check.py

示例4: x

# 需要导入模块: import Quaternion [as 别名]
# 或者: from Quaternion import normalize [as 别名]
q.uniform(rng)
q1.uniform(rng)
print "(%s) x (%s)" % (q, q1)
print q * q1
q *= q1
print q

print "### Quaternion - Multiplication"
print "q = %s" % q
print "magnitude: abs(q)  = %s" % q.magnitude()
print "q1 = %s" % q1
print "magnitude: abs(q1) = %s" % q1.magnitude()
print "### Quaternion - Normalize"
print "q =            %s" % q
print "magnitude: abs(q)  = %s" % q.magnitude()
q.normalize()
print "normalized q = %s" % q
print "magnitude: abs(q)  = %s" % q.magnitude()

q.uniform(rng)
print "q =            %s" % q
print "magnitude: abs(q)  = %s" % q.magnitude()
q.normalize()
print "normalized q = %s" % q
print "magnitude: abs(q)  = %s" % q.magnitude()

q = Quaternion(a = 1000.0002, b = 2.03, c = 0.04, d = 40004.5)
print "q =            %s" % q
print "magnitude: abs(q)  = %s" % q.magnitude()
q.normalize()
print "normalized q = %s" % q
开发者ID:icedmilo,项目名称:FpgaAutoDock,代码行数:33,代码来源:Test.py


注:本文中的Quaternion.normalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。