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.
Unknown said:I mean functions i am using are correct or not ?
I have suggested you correct functions, and you used them correctly, but with wrong data :).
To get correct vectors for calculation of angle you must not just subtract 'some' points. You must subtract specific points in correct order.
Vec[n0] = Point[n - 1] - Point[n];Vec[n1] = Point[n + 1] - Point[n];where Point[n] is a pivot point for rotation. In other words, you need to get two vectors of rays with common start point.
As suggested Jon, first you must understand vector algebra. Without it, this discussion is loosing of time - yours and ours.
Unknown said:I mean functions I am using are correct or not ?
You really need to learn more about computational geometry. Some books about that topic are mentioned here.
Regards, Jon Summers LA Solutions
Jon,
Wrong output may i know where i am doing mistake ?
I mean functions i am using are correct or not ?
Unknown said:Is there any mistake?
Who knows?
Do you expect someone to analyse those numbers for you? Why not draw the result to see what the calculation has produced? Convert your pointArrayP to a line-string element to check visually.
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.74257106782363mdb> DpVer[i].x = 387738.46639060974.y = 7379316.0770320892.z = 580.77082663637952mdb> DpVer[i+2].x = 387734.4656085968.y = 7379315.8822689056.z = 580.70930082661414mdb> dVec1.x = -0.74360178868447713.y = -0.66856083758040796.z = -0.0090986987547425034mdb> dVec2.x = 0.66853223922168625.y = -0.7435669108542966.z = 0.013148924056227015mdb> 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 ?
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 Jon,
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.
Answer Verified By: Daniel Christopher