View Full Version : Circle on Y-Z Plane
BoKirra
2008-12-12, 01:02 AM
Hi ALL,
I'm drawing a circle on Y-Z plane.
My questions about this are:
1) How to write it in the code;
2) What is the best way to do this,
for example
a) draw a circle on X-Y plane normally then do 3drotate;
b) rotate the view to Y-Z plane then draw circle;
c) ...
Your helps would be much appreciated.
T.Willey
2008-12-12, 01:17 AM
What you will want to study is transformation matrices. It is a pretty big concept, and one that will take some studying, but will be really helpful when coding in 3d space. Here is a post by gile on theSwamp, but is very helpful. He might even pop in here and give some advice, as I think he is one of the smarter people when it comes to this.
[ http://www.theswamp.org/index.php?topic=13526.0 ]
edit: Or for this one, you might just be able to study the coordinate system, as you would want to change the normal of the circle ( dxf code 210 ), so that you would be viewing it from that plane instead of the XY plane.
BoKirra
2008-12-12, 01:31 AM
What you will want to study is transformation matrices. It is a pretty big concept, and one that will take some studying, but will be really helpful when coding in 3d space. Here is a post by gile on theSwamp, but is very helpful. He might even pop in here and give some advice, as I think he is one of the smarter people when it comes to this.
[ http://www.theswamp.org/index.php?topic=13526.0 ]
edit: Or for this one, you might just be able to study the coordinate system, as you would want to change the normal of the circle ( dxf code 210 ), so that you would be viewing it from that plane instead of the XY plane.
Thanks for your advice.
I'll have a look on the help which you linked.
kennet.sjoberg
2008-12-12, 09:53 AM
Here is a simple one . . . 3Darc (http://forums.augi.com/showthread.php?t=10671p=61918)
: ) Happy Computing !
kennet
'gile'
2008-12-12, 02:43 PM
Thanks for the compliment, Tim.
If you don't want to use the command method (rotating UCS), the simpler way is the one told by Tim: using 210 DXF code.
The 210 DXF code is the object 'extrusion direction' IOW: the normal of its plane.
The normal vector of YZ plane is 1.0, 0.0, 0.0
So, using entmake to draw a circle in YZ plane, which center is 10.0, 20.0, 0.0 (about this plane, IOW: expressed in OCS coordinates) and radius = 5.0, you just have to specify the 210 DXF code in the entmake list.
(entmake
'((0 . "CIRCLE")
(8 . "Calque1")
(10 10. 20. 0.) ; OCS coordinates
(40 . 5.)
(210 1. 0. 0.) ; Normal
)
)
If you want to use ActiveX, it's quite the same way with the Normal property except the center point has to be WCS coordinates.
You can easily transform OCS coordinates to WCS coordinates with the trans function using the normal vector:
(trans '(10. 20. 0.) '(1. 0. 0.) 0) returns (0.0 10.0 20.0)
(vla-put-Normal
(vla-addCircle
(vla-get-ModelSpace
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
(vlax-3d-point '(0. 10. 20.)); WCS coordinates
5.
)
(vlax-3d-point '(1. 0. 0.)) ; Normal
)
Another way, shoud be to use a transformation matrix to transform a circle drawn in WCS plane to YZ plane.
;;; WCS2Norm (Thanks to Doug Broad)
;;; Returns the 4X4 transformation matrix from WCS to an OCS defined by its Normal
(defun WCS2Norm (norm)
(append
(mapcar
(function
(lambda (vec org)
(append (trans vec 1 0 T) (list org))
)
)
(list '(1 0 0) '(0 1 0) '(0 0 1))
(trans '(0 0 0) 0 norm)
)
(list '(0 0 0 1))
)
)
;;; draw a circle in WCS XY plane
(setq circle
(vla-addCircle
(vla-get-ModelSpace
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
(vlax-3d-point '(10. 20. 0.)); WCS point
5.
)
)
;;; Transform the circle to YZ plane
(vla-TransformBy circle (vlax-tmatrix (WCS2Norm '(1. 0. 0.))))
BoKirra
2008-12-13, 05:37 AM
Here is a simple one . . . 3Darc (http://forums.augi.com/showthread.php?t=10671p=61918)
: ) Happy Computing !
kennet
Thanks for your little tip.
At this moment, I've only learnt a few 3d commands & your help is much appreciated.:beer:
BoKirra
2008-12-13, 05:44 AM
Thanks for the compliment, Tim.
If you don't want to use the command method (rotating UCS), the simpler way is the one told by Tim: using 210 DXF code.
The 210 DXF code is the object 'extrusion direction' IOW: the normal of its plane.
The normal vector of YZ plane is 1.0, 0.0, 0.0
So, using entmake to draw a circle in YZ plane, which center is 10.0, 20.0, 0.0 (about this plane, IOW: expressed in OCS coordinates) and radius = 5.0, you just have to specify the 210 DXF code in the entmake list.
(entmake
'((0 . "CIRCLE")
(8 . "Calque1")
(10 10. 20. 0.) ; OCS coordinates
(40 . 5.)
(210 1. 0. 0.) ; Normal
)
)If you want to use ActiveX, it's quite the same way with the Normal property except the center point has to be WCS coordinates.
You can easily transform OCS coordinates to WCS coordinates with the trans function using the normal vector:
(trans '(10. 20. 0.) '(1. 0. 0.) 0) returns (0.0 10.0 20.0)
(vla-put-Normal
(vla-addCircle
(vla-get-ModelSpace
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
(vlax-3d-point '(0. 10. 20.)); WCS coordinates
5.
)
(vlax-3d-point '(1. 0. 0.)) ; Normal
)Another way, shoud be to use a transformation matrix to transform a circle drawn in WCS plane to YZ plane.
;;; WCS2Norm (Thanks to Doug Broad)
;;; Returns the 4X4 transformation matrix from WCS to an OCS defined by its Normal
(defun WCS2Norm (norm)
(append
(mapcar
(function
(lambda (vec org)
(append (trans vec 1 0 T) (list org))
)
)
(list '(1 0 0) '(0 1 0) '(0 0 1))
(trans '(0 0 0) 0 norm)
)
(list '(0 0 0 1))
)
)
;;; draw a circle in WCS XY plane
(setq circle
(vla-addCircle
(vla-get-ModelSpace
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
(vlax-3d-point '(10. 20. 0.)); WCS point
5.
)
)
;;; Transform the circle to YZ plane
(vla-TransformBy circle (vlax-tmatrix (WCS2Norm '(1. 0. 0.))))
Thanks for your time & You're the real one.
I'll have a look your code when I'm back in office.
Thanks again.:beer:
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.