vanowm Posted February 13 Posted February 13 (edited) Hello. I have 3 objects representing 3 walls of "cube" (corners are not 90 degree). How can I align them so 2 sides of each object is parallel to each other object? I don't know the elevation, so how can I align red and green corners and keeping both objects on blue? Thank you. 3dcorner.dwg Edited February 14 by vanowm Updated the drawing file Quote
BIGAL Posted February 14 Posted February 14 When you select the blue line you can get which segment of the pline you have picked. You can then work out the corner point, or pick the corner point and compare to the pline vertice co-ords so working out where you are. One Gotcha is the direction of pline CW or CCW would make the next step draw shapes go to the wrong side but that can be fixed easy also. Co-ords of blue pline ((35.3085527307455 11.3245385163855) (35.3085527307451 56.7192478838111) (80.6959614192186 55.9051403365565)) Cnr Pick point (35.3085527307451 56.7192478838111 0.0) For a closed shape say 4 points you make a list of 5 pts so can again go forwards and backwards from pick point. So you have a start pt, can work out pline angles so draw your shape. Quote
vanowm Posted February 14 Author Posted February 14 I think you might have misunderstood my dilemma...the shapes are already drawn, they can't be changed, what I'm trying to figure out is how to rotate red and green plines so their edges meet. If blue pline represents floor, then red/green are the walls, I need "stand" them up at proper angle. Quote
lrm Posted February 14 Posted February 14 Given a flat pattern that looks like this. The angle theta needed to rotate each tab up about it edge so that the ends are coincident is: THETA = ACOS(TAN(ALPHA)) Which yields the following. 1 Quote
vanowm Posted February 14 Author Posted February 14 Thank you for the formula, but how do I apply this in autocad? Quote
lrm Posted February 14 Posted February 14 Use the rotate3d command with the 2 point option. After selecting the geometry you want to rotate pick 2 points on the fold line then enter the angle theta. Quote
BIGAL Posted February 14 Posted February 14 Ok understood could be drawn from scratch in one go. If shape is pretty consistent, includes the 3d rotation Like LRM rotate3d 2 points, select 1st pline segment, select 2nd pline segment get theta and then workout the 2 points from the 1st segment. Quote
vanowm Posted February 14 Author Posted February 14 This almost worked, but top corners don't meet. Is ALPHA angle relative to the bottom (stationary) edge, the top or relative to the angle between the walls? I'm getting 15/32" deviation with relative to bottom, 19/64" with relative to top and 9/16" with relative angle between the walls. The THETA I'm calculating with this: (rtod (acos(tan (* pi (/ ALPHA 180.0))))) ( functions borrowed from Lee Mac ) At that stage I could bring them together by using several times ALIGN command... Quote
SLW210 Posted February 14 Posted February 14 I have moved this thread to the AutoCAD 3D Modelling & Rendering Forum. Please post in the correct forum. Quote
lrm Posted February 14 Posted February 14 @vanowm When I derived the formula I assumed that angle B was 90° and that ALPHA was equal to (A - 90) in the following drawing. ALPHA should be the same for both tabs. Is B not 90? Please post you drawing. Quote
vanowm Posted February 14 Author Posted February 14 30 minutes ago, lrm said: @vanowm When I derived the formula I assumed that angle B was 90° and that ALPHA was equal to (A - 90) in the following drawing. ALPHA should be the same for both tabs. Is B not 90? Please post you drawing. Yeah, B is not 90. The drawing is attached to the original post. So, if it's based on the B angle, then the blue numbers should have worked? Quote
vanowm Posted February 14 Author Posted February 14 (edited) Something wrong with the forum, I can download it while logged in, but as a guest it shows as "unavailable" Let's see if it works in reply. 3dcorner.dwg Edited February 14 by vanowm Quote
SLW210 Posted February 14 Posted February 14 You have to be logged in to download AFAIK. Nothing wrong with the forum that I can tell. Quote
lrm Posted February 14 Posted February 14 @vanowm I've modified the formula to handle corners that are not 90°. Here's the revised formula for theta, the bend angle. THETA = acos(tan(ALPHA) / tan(90 - BETA/2)) Here's a LISP program to calculate THETA (defun c:foldangle (/ alpha beta theta) ;; calculate fold angle lrm 2/14/2024 (setq alpha (getreal "\nEnter alpha (deg): ")) (setq beta (getreal "\nEnter beta (deg): ")) (setq theta (acos (/ (tan (/ (* alpha pi) 180)) (tan (- (/ pi 2.) (/ (* beta pi) 360))) ) ) ) (setq theta (/ (* theta 180.) pi)) (princ "\n THETA = ") (princ theta) (princ) ) ;; ArcCosine - Lee Mac ;; Args: -1 <= x <= 1 (defun acos ( x ) (if (<= -1.0 x 1.0) (atan (sqrt (- 1.0 (* x x))) x) ) ) ;; Tangent - Lee Mac ;; Args: x - real (defun tan ( x ) (if (not (equal 0.0 (cos x) 1e-10)) (/ (sin x) (cos x)) ) ) Note that in your drawing the angles for the tabs are not equal. They should be. 1 Quote
vanowm Posted February 14 Author Posted February 14 Thank you very much! It still doesn't make the corners touch...1/2" gap. As of not equal angles - this shouldn't matter, they would just have different lean angle (THETA) Quote
lrm Posted February 14 Posted February 14 (edited) I know the source of the error but not sure how to fix it. I assumed that the edges would be verticaly in line with the BETA angle bisector. They are not if there are two differet angles for ALPHA. I'll have to give it some thought when I have some time. The following should get you closer. THETA RED = 71.043 THETA GREEN = 70.540 Edited February 14 by lrm Quote
lrm Posted February 15 Posted February 15 I think I have an apprach that will yield a solution. I determined the angles graphically in the image below. The green and red circles are on planes perpendicular to the fold axes of the red and green polylines. The yellow point is one of two intersection points of the two circles. I used osnap nearest (zoomed in) to approximate the point. This point can be used to determine the two rotation angles. theta red = 71.533° theta green = 70.733° These angles yield pretty good results with the end points within 0.08. I think even better results could be achieved with a more accurate calculation of the intersection point of the two circles (note, their planes are not perpendicular to each other). I'll try to write some LISP code to determine the intersecion point of two circles on non-parallel planes. Quote
lrm Posted February 15 Posted February 15 (edited) The following program will accurately determine the fold angles and then rotate the two objects so that they meet at a common seam. The user must specify the followinng points. The folding axis for polyline A is a line passing through the corner point and fold line point A. Likewise, the folding axis for polyline B is the line passing through the corner point and the fold line point B. The seams are defined with points A and B. The two polylines must lie on the world XY plane to start. After execution the polylines are rotated about their axes so that the seams are collinear. (defun c:fold (/ pAB pA1 Pb1 pA2 pB2 d pA3 dABA2 pB3 pInters rA rB Az Bz pA4 pB4 thetrA thetrB thetaA thetaB) ; calculates the fold angle for two objects. ; The object must lie on the world XY plane. ; L. Minardi 2/15/2024 (setq pAB (getpoint "\nEnter point at corner of poly A and B.") pA1 (getpoint pAB "\nEnter point on fold line of poly A.") pB1 (getpoint pAB "\nEnter point on fold line of poly B.") pA2 (getpoint pAB "\nEnter point on poly A at seam.") pB2 (getpoint pAB "\nEnter point on poly B at seam.") d (vxv (mapcar '- pA2 pA1) (vx1 (mapcar '- pAB pA1))) pa3 (mapcar '+ ; projection of pA2 to axis A (mapcar '* (vx1 (mapcar '- pAB pA1)) (list d d d) ) pA1 ) dABA2 (distance pAB pA2) ; distance along seam AB to A2 pB2 (mapcar '+ ; adjust pB2 to be same distance along seam pAB (mapcar '* (vx1 (mapcar '- pB2 pAB)) (list dABA2 dABA2 dABA2) ) ) d (vxv (mapcar '- pB2 pB1) (vx1 (mapcar '- pAB pB1))) pb3 (mapcar '+ ; projection of pB2 to axis B (mapcar '* (vx1 (mapcar '- pAB pB1)) (list d d d) ) pB1 ) pInters (inters pA2 pA3 pB2 pB3) ; intersection of two planes rA (distance pA2 pA3) ; radius A rB (distance pB2 pB3) ; radius B Az (sqrt ; z coordnate for rotated pA2 (- (expt ra 2) (expt (distance pInters pA3) 2) ) ) pA4 (list (car pInters) (cadr pInters) Az) ; final location for pA2 thetrA ; rotation angle in radians for poly A (acos (vxv (vx1 (mapcar '- pInters pA3)) (vx1 (mapcar '- pA4 pA3)) ) ) thetaA (/ (* thetrA 180.) pi) ) (princ "\ntheta A = ") (princ thetaA) (setq Bz (sqrt ; z coordinate for rotated pB2 (- (expt rB 2) (expt (distance pInters pB3) 2) ) ) ) (setq pB4 (list (car pInters) (cadr pInters) Bz)) (setq thetrB ; rotation angle in radians for poly B (acos (vxv (vx1 (mapcar '- pInters pB3)) (vx1 (mapcar '- pB4 pB3)) ) ) ) (setq thetaB (/ (* thetrB 180.) pi)) (princ "\ntheta B = ") (princ thetaB) ;(setq polyA (car (entsel "\nSelect polyline A"))) ;(setq polyB (car (entsel "\nSelect polyline B"))) ;(command "_rotate3d" polyA "" "2" pA1 pAB thetaA) ;(command "_rotate3d" polyB "" "2" pAB pB1 thetaB) (rotatepoly) (princ) ) (defun rotatepoly (/) (setq polyA (car (entsel "\nSelect polyline A")) polyB (car (entsel "\nSelect polyline B")) ) (command "_rotate3d" polyA "" "2" pA1 pAB thetaA) (command "_rotate3d" polyB "" "2" pAB pB1 thetaB) (princ) ) ;; ArcCosine - Lee Mac ;; Args: -1 <= x <= 1 (defun acos ( x ) (if (<= -1.0 x 1.0) (atan (sqrt (- 1.0 (* x x))) x) ) ) ;; Tangent - Lee Mac ;; Args: x - real (defun tan ( x ) (if (not (equal 0.0 (cos x) 1e-10)) (/ (sin x) (cos x)) ) ) ;; Vector Dot Product - Lee Mac ;; Args: u,v - vectors in R^n (defun vxv ( u v ) (apply '+ (mapcar '* u v)) ) ;; Vector Cross Product - Lee Mac ;; Args: u,v - vectors in R^3 (defun v^v ( u v ) (list (- (* (cadr u) (caddr v)) (* (cadr v) (caddr u))) (- (* (car v) (caddr u)) (* (car u) (caddr v))) (- (* (car u) (cadr v)) (* (car v) (cadr u))) ) ) ;; Unit Vector - Lee Mac ;; Args: v - vector in R^2 or R^3 (defun vx1 ( v ) ( (lambda ( n ) (if (equal 0.0 n 1e-10) nil (mapcar '/ v (list n n n)))) (distance '(0.0 0.0 0.0) v) ) ) Edited February 15 by lrm 1 Quote
vanowm Posted February 15 Author Posted February 15 Wow that's more than I was expecting! Thank you very much, works perfectly! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.