Jump to content

Recommended Posts

Posted (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?

 

image.thumb.png.1497580cdab16d4ae15558312a4711d8.png

 

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 by vanowm
Updated the drawing file
Posted

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.

Posted

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.

Posted

Given a flat pattern that looks like this.

image.png.b483c02bb855b1341ad02396b12a89d3.png

 

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.

image.png.2e1119d895100e076eb56701e3ab3c31.png

image.png.691f4538ee363265bd792047f591bbfe.png

image.png

  • Thanks 1
Posted

Thank you for the formula, but how do I apply this in autocad?

Posted

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.

Posted

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.

 

Posted

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?

image.thumb.png.4a79588aaa24d253956564985dea282c.png

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...

Posted

@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.

 

image.thumb.png.4d1f0baeb5d87469f9359d3bb11d80d9.png

Posted
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?

Posted (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 by vanowm
Posted

You have to be logged in to download AFAIK. Nothing wrong with the forum that I can tell.

Posted

@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))   

image.png.e89e2815371017fece9c26c30d571d9a.png

 

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.

image.png.8d0598502362ec0b86945bb7a41f7ea8.png

 

  • Thanks 1
Posted

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)

Posted (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 by lrm
Posted

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. 

 

image.thumb.png.91090cb980241d3c391d1c954be6fb90.png

Posted (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.

image.png.29674ceecd01c13f28f55128da8de140.png

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.

image.png.ec4387ec9aa02a0d62320c9341809c87.png

(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 by lrm
  • Thanks 1
Posted

Wow that's more than I was expecting! Thank you very much, works perfectly!

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...