天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 11|回复: 0

块的角度

[复制链接]
  • TA的每日心情
    开心
    昨天 15:23
  • 签到天数: 69 天

    [LV.6]常住居民II

    410

    主题

    167

    回帖

    2704

    积分

    管理员

    积分
    2704
    发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
    if (m_BlockRef)
            {
                    delete m_BlockRef;
                    m_BlockRef = nullptr;
            }

            m_DirPt = dir_pt;
            m_BlockRef = new AcDbBlockReference();
            m_BlockRef->setBlockTableRecord(blk_objid);

            // Calcualte Normal : refactor as function
            AcGeVector3d vec = endPoint().asVector() - startPoint().asVector();
            AcGeVector3d vec1 =m_DirPt.asVector() - startPoint().asVector();
            AcGeVector3d vec_normal = vec.crossProduct(vec1);
            vec_normal.normalize();

            // Get UCS, refactor as a function
            AcGeMatrix3d  myUCS;
            acdbUcsMatrix(myUCS, nullptr);
            AcGeVector3d  xAxis, yAxis, zAxis;
            AcGePoint3d   myOrigin;
            myUCS.getCoordSystem(myOrigin, xAxis, yAxis, zAxis);

            bool AngleFlip = false;
            if (fabs (vec_normal.dotProduct(zAxis) ) < 1e-8)
                    return;
            else if (vec_normal.dotProduct(zAxis)  < 0)
                    AngleFlip = true;
            else
                    AngleFlip = false;

            m_BlockRef->setNormal(zAxis) ; //(vec_normal);
            m_BlockRef->setPosition(ins_pt);
            AcGeScale3d scl;
            if (scale < 0)
                    scale = 1.0;
            scl.set(scale, scale, scale);
            m_BlockRef->setScaleFactors(scl);

            // calculate angle
            ads_point p_start_wcs, p_end_wcs, p_start_ucs, p_end_ucs;
            p_start_wcs[X] = startPoint().x ; p_start_wcs[Y] = startPoint().y ; p_start_wcs[Z] = startPoint().z;
            p_end_wcs[X] = endPoint().x ; p_end_wcs[Y] = endPoint().y ; p_end_wcs[Z] = endPoint().z;
            ConvertFromWCSToUCS(p_start_wcs, p_start_ucs);
            ConvertFromWCSToUCS(p_end_wcs, p_end_ucs);
            AcGePoint3d p_start(p_start_ucs[X], p_start_ucs[Y], p_start_ucs[Z]);
            AcGePoint3d p_end(p_end_ucs[X], p_end_ucs[Y], p_end_ucs[Z]);
            AcGeVector3d v1_ucs = p_end.asVector() - p_start.asVector();
            AcGeVector3d v1 = endPoint().asVector() - startPoint().asVector();

            AcGeVector3d ref_vector = AcGeVector3d::kZAxis;
            double dangle  = xAxis.angleTo(v1_ucs, zAxis); // this is not what I want?
            double dangle1 = AcGeVector3d::kXAxis.angleTo(v1_ucs,AcGeVector3d::kZAxis);

            if (m_AngleFlip )
            {
                    dangle1 *= -1;
                    m_FlipHandle = !m_FlipHandle;
            }
            m_BlockRef->setRotation(dangle1 );

     

     

     

     

    块的角度
    中国膜结构网打造全中国最好的膜结构综合平台 ,统一协调膜结构设计,膜结构施工,膜材采购,膜材定制,膜结构预算全方位服务。 中国空间膜结构协会合作单位。
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|

    GMT+8, 2024-7-1 05:59 , Processed in 0.057854 second(s), 22 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表