PointCloud.us - A PolyWorks Support Forum

PolyWorks Discussion => Inspector => Topic started by: Jeff on March 09, 2010, 05:34:31 AM

Title: Vector tangent to a circle
Post by: Jeff on March 09, 2010, 05:34:31 AM
Is there an easy way to create a vector tangent to a circle and parallel to y axis? Thanks! Jeff
Title: Re: Vector tangent to a circle
Post by: Admin on March 09, 2010, 05:54:41 AM
I have never done this, but remember many times wanting to ... I'm eager to find out too.
Title: Re: Vector tangent to a circle
Post by: ONCommand on March 11, 2010, 01:31:41 AM
Since You should have all necessary information(in the feature), I think you might realize this with a macro.

But by now, I do not know exaktly what you mean?
E.g. there are mostly two tangents to a circle parallel to Y axis ...
and is it made sure, that the circle is exactly orientated in the XY-Plane or YZ Plane?

regards, Oliver



Title: Re: Vector tangent to a circle
Post by: Jeff on March 11, 2010, 05:04:20 AM
I see Oliver?s point. We have other software that will let you do this but it is threw a point tangent to a circle or tangent to two circles. After you select the two circles it will ask you what side to project them to. Thanks everyone for the reply.
Title: Re: Vector tangent to a circle
Post by: ONCommand on March 11, 2010, 12:20:01 PM
Hello Jeff!

I thought a bit about your question and realized a small macro, which does what you ask for in your first post.
(at last two tangents will be created)
Since every tangent to a circle is always orthogonal to its axis, this would only work with nominals, where one axis orientation is exactly 0 ...

I do not test any circle orientation , so there might be some bugs ...


# Create Tangent to Circle
# Macro creates two tangents to a circle parallel to a specified axis
# (c)2010 O.Niessen
# http://www.ONCommand.de

### Todo:  test for all possible circle orientation 10/03/11###
version "4.0"


# ----- Declare some error messages -----
Declare ErrorMsgTitle "Circle-tangent error"
Declare ErrorMsgNumber "More than one or no complete feature selected!!"
Declare ErrorMsgCircle "No circle selected!!"
Declare ErrorMsgOrto "Circle is not orthogonal to axis!!"
# ----- Declare Message Text -----
Declare AxisMsgTitle "Parallel axis?"
Declare AxisMsgText "Specify the desired parallel axis"

# -----  some error Handling -----
DECLARE NB_selected 0
TREEVIEW FEATURE GET_NB_SELECTED(NB_selected)
IF $NB_selected != 1
    MACRO PAUSE($ErrorMsgTitle, $ErrorMsgNumber)
    MACRO END
ENDIF
SET NB_selected 0
TREEVIEW FEATURE CIRCLE GET_NB_SELECTED(NB_selected)
IF $NB_selected != 1
    MACRO PAUSE($ErrorMsgTitle, $ErrorMsgCircle)
    MACRO END
ENDIF
# -----------------------------------------


# --- Get ID of selected circle ----
DECLARE breakpoint
DECLARE select "Off"
DECLARE i 0
TREEVIEW FEATURE CIRCLE GET_NB (breakpoint)
While $select != "On"
    ++i
    if $i > $breakpoint
        break
    endif
    TREEVIEW FEATURE CIRCLE GET_SELECTION_STATUS ($i, select) 
endwhile

# ---- Read out circle nominal values ----
DECLARE Center_X
DECLARE Center_Y
DECLARE Center_Z
DECLARE Axis_X
DECLARE Axis_Y
DECLARE Axis_Z
DECLARE Radius
DECLARE C_Name
TREEVIEW FEATURE CIRCLE GET_NAME ($i, C_Name)

TREEVIEW FEATURE CIRCLE NOMINAL SELECT($i)
TREEVIEW PRIMITIVE CIRCLE PROPERTIES CENTER GET(Center_X, Center_Y, Center_Z)
TREEVIEW PRIMITIVE CIRCLE PROPERTIES AXIS_ORIENTATION GET(Axis_X, Axis_Y, Axis_Z)
TREEVIEW PRIMITIVE CIRCLE PROPERTIES RADIUS GET (Radius)

# --- Input of the parallel Axis ----
DECLARE P_Axis
INPUT STRING(P_Axis, $AxisMsgTitle, $AxisMsgText, "x" )
# May be simpler, to look, which axis is/are orthogonal to circle axis
# then maximally 4 tangents may be created


# ------- Execution --------
# May create a false tangents , depending on Circle-axis-orientation/Circle-center-orientation
### Todo:  test for all possible circle orientation 10/03/11###

Declare Vector_X
Declare Vector_Y
Declare Vector_Z

IF $P_Axis == "x"
        IF $Axis_X > 0
        # -----  some error Handling -----
        MACRO PAUSE($ErrorMsgTitle, $ErrorMsgOrto)
        MACRO END
        ENDIF
    #    Build the nominal vectors with length of 25
    set Vector_X $center_X
    set Vector_Y expr($center_Y - $Radius * -$Axis_Z)
    set Vector_Z expr($center_Z - $Radius * $Axis_Y)
    FEATURE PRIMITIVE VECTOR CREATE($Vector_X, $Vector_Y, $Vector_Z, 1, 0, 0, 25, "nominal","X-tangent 1 to $C_Name")
    set Vector_X $center_X
    set Vector_Y expr($center_Y - $Radius * $Axis_Z)
    set Vector_Z expr($center_Z - $Radius * -$Axis_Y)
    FEATURE PRIMITIVE VECTOR CREATE($Vector_X, $Vector_Y, $Vector_Z, 1, 0, 0, 25, "nominal","X-tangent 2 to $C_Name")
ENDIF
IF $P_Axis == "y"
    IF $Axis_Y > 0
    # -----  some error Handling -----   
    MACRO PAUSE($ErrorMsgTitle, $ErrorMsgOrto)
    MACRO END
    ENDIF       
    #    Build the nominal vectors with length of 25
    set Vector_Y $center_Y
    set Vector_X expr($center_X - $Radius * -$Axis_Z)
    set Vector_Z expr($center_Z - $Radius * $Axis_X)
    FEATURE PRIMITIVE VECTOR CREATE($Vector_X, $Vector_Y, $Vector_Z, 0, 1, 0, 25, "nominal","Y-tangent 1 to $C_Name")
    set Vector_Y $center_Y
    set Vector_X expr($center_X - $Radius * $Axis_Z)
    set Vector_Z expr($center_Z - $Radius * -$Axis_X)
    FEATURE PRIMITIVE VECTOR CREATE($Vector_X, $Vector_Y, $Vector_Z, 0, 1, 0, 25, "nominal","Y-tangent 2 to $C_Name")
ENDIF
IF $P_Axis == "z"
    IF $Axis_Z > 0
    # -----  some error Handling -----   
    MACRO PAUSE($ErrorMsgTitle, $ErrorMsgOrto)
    MACRO END
    ENDIF
    #    Build the nominal vectors with length of 25
    set Vector_Z $center_Z
    set Vector_X expr($center_X - $Radius * -$Axis_Y)
    set Vector_Y expr($center_Y - $Radius * $Axis_X)
    FEATURE PRIMITIVE VECTOR CREATE($Vector_X, $Vector_Y, $Vector_Z, 0, 0, 1, 25, "nominal",,"Z-tangent 1 to $C_Name")
    set Vector_Z $center_Z
    set Vector_X expr($center_X - $Radius * $Axis_Y)
    set Vector_Y expr($center_Y - $Radius * -$Axis_X)
    FEATURE PRIMITIVE VECTOR CREATE($Vector_X, $Vector_Y, $Vector_Z, 0, 0, 1, 25, "nominal",,"Z-tangent 2 to $C_Name")   
ENDIF


Feel free to modify it or use it as Idea... :-)

I think a macro to create any tangent from a point to a circle(if possible) or between two circles(in the same plane!!! and if possible...) could be realized in a similar way...


regards, Oliver

Title: Re: Vector tangent to a circle
Post by: Jeff on March 12, 2010, 01:44:53 AM
 ;D Thanks for the macro Oliver. I will have to try that. I also found out how to do this the way I want it to work.

Go to Tool Bar and click on Feature go down to Primitives, Vector, and then Create from Points & Offsets. Drag the circle to both offset boxes. Then just change x2, y2, or z2 to get the length of your line. It will put a vector on both sides of the circle. If you would like to do tangent to two circles then just drag one circle to offset one and the other to offset two. This works the same with a point. Thanks! Jeff