How to find angle Alpha,chi and distance Z.

  • Dear Jayasuriya,

    thank you for your question:


    I am having doubts in applet). How to find center of gravity of object,angle alpha,angle chi and distance Z...."

    Please find attached a sketch of the patterns A and B ( part of object) and the Center of gravity (COG) of object.

    If you want to rotate not around the center of gravity you can chhoose any other point to rotate around. You can select any pattern on the objects. I recommend to select patterns which appear only one time in the object and are mostly rotation invariant.

    In the image in the attachment also the angles alpha, chi and the distance Z between pattern A and the COG are sketched.

    Calculation of angle alpha:

    with x_A, y_A : x and y coordinate of pattern A,

    x_B, y_B : x and y coordinate of pattern B,

    x_COG, y_COG: y coordinate of COG

    alpha= arctan((y_A - y_COG)/(x_COG-x_A))-chi)

    calculation of angle chi

    chi=arctan((y_A - y_B)/(x_B-x_A))

    calculation of distance Z:


    Please see also under…%20Inspection%20Blob.html a detailed documentation on the design ""

    Also the design "" maybe of interest for you:

    In this design the rotation angle and position shift calculation of an object is not pattern based but it is based on the calculation of image moments

    (see e.g.

    Concerning your question


    In ''split fraction and integer bit'' hierarchical box which conversion is used to convert 959 into 15712255 (input to 'is in range' operator)..."

    In the hierarchical box "LimitCoordinateValues" in module "SplitFractional And IntegerBit" the coordinates are limited to the maximum input image coordinates. Due to the geometric transformation performed in module "InverseTrabnsformation" in module "geometricTransformation" 14 fractional bits remain.

    This means coordinate of 959 corresponds to 959*2^14=15712255.

    I hope to help you with these explanations.

    Best regards

    Carmen Z

  • Dear Jayasuriya,

    thank you for your question. We use this procedure because only interger values are allowed for the parameters in VisualApplets.

    The reference angle chi and alpha is multiplied by a factor 1024/90, to covert degree to fixed point parameter value

    I.E. 90°= 1024, and 27,77°= 316

    Also the multiplication by a factor of 2^2=4 of the distance is due to the fixed point t arithmetic and correspond to the subpixel accuracy.

    This means: 2^2 correspond to distance of 1. If you like to set a distance Z of 0.5 we use value of 2 in VisualApplets.

  • Dear JSuriya,

    thank you for your request.

    Do you refer to the Visual Applets example ""?

    Please may you explain "reference points"? Do you mean rotation, translation and scaling with respect to a certain point (E.g center of gravity)?

    Of cource instead of rotation around center of gravity you can choose any other point in the image to perform the transformation.