Adjust Building Edges to 90 Degrees using MDL's

Hi Guys,

Please find the attached image.

Requirement:Need to adjust building edges to 90 Degrees, based on the specified angle.

For Example building contains10 vertices, first i am finding angle between vertex 0,1 & 2 next 1,2 & 3 and so on ......

For Example user specified angle is 2 degrees, need to adjust the edge(if the angle lies between 88 and 92 Degrees) to 90 Degrees.

Here is the code

mdlLinear_extract(DpVer,&NumVert,&MsEleDsc->el,MASTERFILE);
 for(i=0;i<NumVert;i++)
 {
                    if(i+2 < NumVert)
                    {
                        
                        mdlVec_computeNormal(&dVec1,&DpVer[i],&DpVer[i+1]) ;
                        mdlVec_computeNormal(&dVec2,&DpVer[i+1],&DpVer[i+2]);    
                        
                        mdlVec_normalize(&dVec1);
                        mdlVec_normalize(&dVec2);

                        Angle = mdlVec_angleBetweenVectorsXY(&dVec1,&dVec2);
                        Angle = (3.14159265 - Angle) / 0.0174532925199433 ;

                        if(((Angle> (90 - <User specified angle>)) && (Angle< (90 + <User specified angle>))))
                        {
                                            
                        }
                    }
  }

Successfully finding the angle between the 3 vertices.

Questions:

How to adjust the edge to 90 degrees (if the angle lies between user specified Angle) ?

2nd Vertex must be modified to set the angle to 90 Degrees but how ?

I am not asking for code ;-) , suggest me how can i adjust the edge to 90 Degrees.

Parents
    • Get the normal of the plane formed by the two vectors (hint: cross-product)
    • Rotate vec1 by 90° about that normal

    Unknown said:
    Need to adjust building edges to 90°

    I appreciate that you're involved in data cleanup, but it would be preferable if the CAD users were to take advantage of MicroStation's tools.  Built-in capability such as the AccuDraw compass enables the construction of accurate drawings.  Using those tools would make cleanup tools redundant.

     
    Regards, Jon Summers
    LA Solutions

    Answer Verified By: Daniel Christopher 

  • Hi Jon,

    • Normal of the plane "mdlVec_normalizedCrossProduct(&Planenormal,&dVec1,&dVec2);"
    • Rotate vec1 by 90° about that normal ( vec1 == dVec1 ?)
    • How to rotate vec1 by 90 Degrees using "Planenormal" ?

  • 1.) use mdlVec_subtractDPoint3dDPoint3d to get vectors

    2.) calculate angle between those vectors and their crossproduct (check normal's directon)

    3.) create a transform matrix using mdlTMatrix_fromRotationAroundPointAndVector

    4.) use matrix to rotate points using mdlTMatrix_transformPointArray

  • Hi Dan,

    1)  mdlVec_subtractDPoint3dDPoint3d(&dVec1,&DpVer[i+1],&DpVer[i]);
          mdlVec_subtractDPoint3dDPoint3d(&dVec2,&DpVer[i+1],&DpVer[i+2]);

          mdlVec_normalize(&dVec1);
          mdlVec_normalize(&dVec2);

    2)   Angle = mdlVec_angleBetweenVectorsXY(&dVec1,&dVec2);
           Angle = (3.14159265 - Angle) / 0.0174532925199433 ;

          mdlVec_normalizedCrossProduct(&pCrossProduct,&dVec1,&dVec2);

    3)  mdlTMatrix_fromRotationAroundPointAndVector(&transformP,&DpVer[i],&pCrossProduct,1.570796327);

    4)  mdlTMatrix_transformPointArray(pointArrayP,&transformP,3);

    Output:

    mdb> pointArrayP

    [0].x = 7719526.9854165446
    [0].y = 8296675.8804530893
    [0].z = 89445.407045140397
    [1].x = 7719261.6575013353
    [1].y = 8296629.4354537418
    [1].z = 89441.641368713914
    [2].x = 252610.33324784692
    [2].y = 6846384.9664532244
    [2].z = -131219.73550886242

    mdb> DpVer[i+1]

    .x = 387736.15717124939
    .y = 7379314.0008487701
    .z = 580.74257106782363
    mdb> DpVer[i]

    .x = 387738.46639060974
    .y = 7379316.0770320892
    .z = 580.77082663637952
    mdb> DpVer[i+2]

    .x = 387734.4656085968
    .y = 7379315.8822689056
    .z = 580.70930082661414
    mdb> dVec1

    .x = -0.74360178868447713
    .y = -0.66856083758040796
    .z = -0.0090986987547425034
    mdb> dVec2

    .x = 0.66853223922168625
    .y = -0.7435669108542966
    .z = 0.013148924056227015
    mdb> transformP

    .form3d[0][0] = 0.00024199973070624249
    .form3d[0][1] = -0.99992964356085534
    .form3d[0][2] = -0.011859568474073356
    .form3d[0][3] = 7766448.4161071312
    .form3d[1][0] = 0.99981468868857593
    .form3d[1][1] = 1.3651268208498285e-005
    .form3d[1][2] = 0.019250664825116434
    .form3d[1][3] = 6991537.5457176892
    .form3d[2][0] = -0.019249148518738095
    .form3d[2][1] = -0.011862029417590094
    .form3d[2][2] = 0.99974434859087868
    .form3d[2][3] = 94997.448188310969

    Is there any mistake ?

Reply
  • Hi Dan,

    1)  mdlVec_subtractDPoint3dDPoint3d(&dVec1,&DpVer[i+1],&DpVer[i]);
          mdlVec_subtractDPoint3dDPoint3d(&dVec2,&DpVer[i+1],&DpVer[i+2]);

          mdlVec_normalize(&dVec1);
          mdlVec_normalize(&dVec2);

    2)   Angle = mdlVec_angleBetweenVectorsXY(&dVec1,&dVec2);
           Angle = (3.14159265 - Angle) / 0.0174532925199433 ;

          mdlVec_normalizedCrossProduct(&pCrossProduct,&dVec1,&dVec2);

    3)  mdlTMatrix_fromRotationAroundPointAndVector(&transformP,&DpVer[i],&pCrossProduct,1.570796327);

    4)  mdlTMatrix_transformPointArray(pointArrayP,&transformP,3);

    Output:

    mdb> pointArrayP

    [0].x = 7719526.9854165446
    [0].y = 8296675.8804530893
    [0].z = 89445.407045140397
    [1].x = 7719261.6575013353
    [1].y = 8296629.4354537418
    [1].z = 89441.641368713914
    [2].x = 252610.33324784692
    [2].y = 6846384.9664532244
    [2].z = -131219.73550886242

    mdb> DpVer[i+1]

    .x = 387736.15717124939
    .y = 7379314.0008487701
    .z = 580.74257106782363
    mdb> DpVer[i]

    .x = 387738.46639060974
    .y = 7379316.0770320892
    .z = 580.77082663637952
    mdb> DpVer[i+2]

    .x = 387734.4656085968
    .y = 7379315.8822689056
    .z = 580.70930082661414
    mdb> dVec1

    .x = -0.74360178868447713
    .y = -0.66856083758040796
    .z = -0.0090986987547425034
    mdb> dVec2

    .x = 0.66853223922168625
    .y = -0.7435669108542966
    .z = 0.013148924056227015
    mdb> transformP

    .form3d[0][0] = 0.00024199973070624249
    .form3d[0][1] = -0.99992964356085534
    .form3d[0][2] = -0.011859568474073356
    .form3d[0][3] = 7766448.4161071312
    .form3d[1][0] = 0.99981468868857593
    .form3d[1][1] = 1.3651268208498285e-005
    .form3d[1][2] = 0.019250664825116434
    .form3d[1][3] = 6991537.5457176892
    .form3d[2][0] = -0.019249148518738095
    .form3d[2][1] = -0.011862029417590094
    .form3d[2][2] = 0.99974434859087868
    .form3d[2][3] = 94997.448188310969

    Is there any mistake ?

Children