Find the rotation of a quad (4 points, planar)

Find the rotation of a quad (4 points, planar)

By : wheetom
Date : October 19 2020, 08:10 AM
Does that help It's easy enough to get the matrix that represents that orientation; you can work backwards from that to rotations.
If you're sure the quad is planar, you can just use the face normal (which should be equivalent to any of the vertex-face normals). If not, you can derive it from the cross vectors as you tried to do in your example. If the geometry is really planar the results will be the same.
code :
import pymel.core as pm
from pymel.core.datatypes import Matrix, Vector, TransformationMatrix

points = [Vector(pm.xform('pPlane1.vtx[%i]' % i, q=True, t=True, ws=True))  for i in range(4)]

local_x = (points[1] - points[0]).normal()
local_z = (points[2] - points[0]).normal()
local_y = local_x.cross(local_z).normal()
centroid = sum(points) / 4.0
 matrix = TransformationMatrix (
               local_x.x, local_x.y, local_x.z, 0,
               local_y.x, local_y.y, local_y.z, 0,
               local_z.x, local_z.y, local_z.z, 0,
               centroid.x, centroid.y, centroid.z, 1
locator = pm.spaceLocator()
pm.xform(locator, m=matrix, ws=True)
eulers = matrix.getRotation()
quat = matrix.getRotationQuaternion()

Share : facebook icon twitter icon
How can I find the rotation of a quad in 3D?

How can I find the rotation of a quad in 3D?

By : COBRAws
Date : March 29 2020, 07:55 AM
it helps some times OK. I am frankly still not really clear on what it is you're looking for, but let me try to clarify the problem and then address my best guess as to what you really want and see if that helps.
As mentioned in the comment thread, a rotation is a transformation that maps one set of stuff (eg, vectors A, B, C...) to a different set of stuff (A', B', C'...). We can fully define this transformation in terms of an angle (call it θ) and an axis of rotation we'll call R.
code :
theta0 = atan2(A.x, A.y);
theta1 = atan2(A_prime.x, A_prime.y);
theta = theta1 - theta0;
// A and B are adjacent corners of the square
// B - A is the direction of the edge joining them
// theta is the angle between that side and the X axis
// (rotating by -theta around Z should align the square)
theta = atan2(B.x - A.x, B.y - A.y);
theta1 = -atan2(x,y);
hypoXY = sqrt(x*x + y*y);
c1 = x/hypoXY;
s1 = y/hypoXY;
[  c1  s1  0 ]
[ -s1  c1  0 ]
[  0   0   1 ]
theta2 = -atan2(z, sqrt(x*x + y*y));
c2 = z;
s2 = hypoXY;
[ c2  0  -s2 ]
[ 0   1   0  ]
[ s2  0   c2 ]
[  c2c1   c2s1  -s2  ]
[ -s1     c1     0   ]
[  s2c1   s2s1  c2   ]
Camera pixels to planar world points given 4 known points

Camera pixels to planar world points given 4 known points

By : user2400406
Date : March 29 2020, 07:55 AM
will help you try this approach:
compute the homography from 4 point correspondences, giving you all information to transform between image plane and ground plane coordinates.
code :
cv::Point2f transformPoint(cv::Point2f current, cv::Mat transformation)
    cv::Point2f transformedPoint;
    transformedPoint.x = current.x * transformation.at<double>(0,0) + current.y * transformation.at<double>(0,1) + transformation.at<double>(0,2);
    transformedPoint.y = current.x * transformation.at<double>(1,0) + current.y * transformation.at<double>(1,1) + transformation.at<double>(1,2);
    float z = current.x * transformation.at<double>(2,0) + current.y * transformation.at<double>(2,1) + transformation.at<double>(2,2);
    transformedPoint.x /= z;
    transformedPoint.y /= z;

    return transformedPoint;

int main()
    // image from http://d20uzhn5szfhj2.cloudfront.net/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/5/2/52440-chess-board.jpg

    cv::Mat chessboard = cv::imread("../inputData/52440-chess-board.jpg");

    // known input:
    // image locations / read pixel values
    //  478,358
    //  570, 325
    //  615,382
    //  522,417

    std::vector<cv::Point2f> imageLocs;
    imageLocs.push_back(cv::Point2f(570, 325));

    for(unsigned int i=0; i<imageLocs.size(); ++i)
        cv::circle(chessboard, imageLocs[i], 5, cv::Scalar(0,0,255));
    cv::imwrite("../outputData/chessboard_4points.png", chessboard);

    // known input: this is one field of the chessboard. you could enter any (corresponding) real world coordinates of the ground plane here.
    // world location:
    // 3,3
    // 3,4
    // 4,4
    // 4,3

    std::vector<cv::Point2f> worldLocs;

    // for exactly 4 correspondences. for more you can use cv::findHomography
    // this is the transformation from image coordinates to world coordinates:
    cv::Mat image2World = cv::getPerspectiveTransform(imageLocs, worldLocs);
    // the inverse is the transformation from world to image.
    cv::Mat world2Image = image2World.inv();

    // create all known locations of the chessboard (0,0) (0,1) etc we will transform them and test how good the transformation is.
    std::vector<cv::Point2f> worldLocations;
    for(unsigned int i=0; i<9; ++i)
        for(unsigned int j=0; j<9; ++j)

    std::vector<cv::Point2f> imageLocations;

    for(unsigned int i=0; i<worldLocations.size(); ++i)
        // transform the point
        cv::Point2f tpoint = transformPoint(worldLocations[i], world2Image);
        // draw the transformed point
        cv::circle(chessboard, tpoint, 5, cv::Scalar(255,255,0));

    // now test the other way: image => world
    cv::Point2f imageOrigin = cv::Point2f(87,291);
    // draw it to show which origin i mean
    cv::circle(chessboard, imageOrigin, 10, cv::Scalar(255,255,255));
    // transform point and print result. expected result is "(0,0)"
    std::cout << transformPoint(imageOrigin, image2World) << std::endl;

    cv::imshow("chessboard", chessboard);
    cv::imwrite("../outputData/chessboard.png", chessboard);

[0.174595, 0.144853]
In a Quad tree of points, how do you partition a quad if your insert point falls exactly on the partition line?

In a Quad tree of points, how do you partition a quad if your insert point falls exactly on the partition line?

By : 学习者SID
Date : March 29 2020, 07:55 AM
should help you out The usual definition for rectangles is that the left and lower border is included (part of the rectangle), and the right and upper border is excluded.
This will be considered in the splitting code using the appropriate < and <= related to that rule.
Using OpenCV to Solve for Transform between non planar object Points and image points

Using OpenCV to Solve for Transform between non planar object Points and image points

By : phanjo33
Date : March 29 2020, 07:55 AM
Any of those help (Sorry forgot to follow up on this)
Calculate the determinant of the rotation matrix. It should be =1 for a 'correct' answer and -1 for the flipped one. Then simply multiply the rotation by a identity matrix where the last term is the determinant. this does nothing if the det() =1 but flips it back to the correct answer if the det() is = -1
Given a set of points, find if there exists a convex quad from these points with no points other then its corners are in

Given a set of points, find if there exists a convex quad from these points with no points other then its corners are in

By : user2601529
Date : March 29 2020, 07:55 AM
it helps some times Create a Delauny triangulation. Find two adjacent triangles inside the convex hull (it means at least one of them is not located over convex hull) and report! To find more about Delauny triangulation read here.
As if there is any concave angle between four adjacent points, it will be flipped we can say every four adjacent points inside the convex hull create a convex quad.
Related Posts Related Posts :
  • How to exit/terminate a job earlier and handle the raised exception in apscheduler?
  • python, print intermediate values while loop
  • python to loop over yaml config
  • D3.js is not recognized by PyCharm
  • Access the regularization paths obtained from ElasticNetCV in sklearn
  • Pattern table to Pandas DataFrame
  • Get the earliest date from a column (Python Pandas) after csv.reader
  • Get SystemError: Parent module '' not loaded, cannot perform relative import when trying to import numpy in a Cython Ext
  • Bash or Python : Append and prepend a string recursively in all .tex files
  • Changing a certain index of boolean list of lists change others, too
  • complex dataframe filtering request on the last occurence of a value in Panda/Python [EDIT]
  • How to repeatedly get the contents of a Text widget every loop with tkinter?
  • How to call the tornado.queues message externally
  • How can I use regex in python so that characters not included are disallowed?
  • Discarding randmly scattered empty spaces in pandas data frame
  • Get sums grouped by date by same column filtered by 2 conditions
  • Element disappears when I add an {% include %} tag inside my for loop
  • Django Rest Framework with either a slug or a pk lookup field for the DetailAPIView
  • Flask doesn't stream on Lambda
  • Generate all permutations of fixed length where the elements come from two different sets
  • Making function for calculating distance
  • How to handle multiprocessing based on the limit of CPU's
  • Django - static files is not working
  • Remove x axis and y axis black lines with matplotlib
  • tkinter: assigning multiple functions to one button
  • flask-jwt-extended: Fake Authorization Header during testing (pytest)
  • Setting pandas dataframe value based on row and column conditions
  • swig char ** as a pointer to a char *
  • Confusion over `a` and `b` attributes from scipy.stats.uniform
  • How can I do groupy.apply() without sort my index?
  • Querying Google Cloud datastore with ancestor not returning anything
  • Read value from one thread in Python: queue or global variable?
  • Django - context process query being repeated 102 times
  • Convert a list of images and labels to np array to train tensorflow
  • Lambda not supporting NLTK file size
  • Numpy ndarray image pixel mean for pixel values greater than zero: Normalizing image
  • Understanding output of np.corrcoef for two matrices of different sizes
  • Finding longest perfect match between two strings
  • what is wrong with my cosine similarity? Tensorflow
  • How to manage user content in django?
  • Receiving unsupported operand error while comparing random number and user input.
  • How to wrap the process of creating start_urls in scrapy?
  • How to mark 'duplicated sequence' in pandas?
  • Boolean indexing on multidimensionnal array
  • Unmodified column name index in patsy
  • Cleaner way to unpack nested dictionaries
  • Importing a python module to enable a script to be run from command line
  • Maya Python read and set optionMenu value via variable
  • How can I bind a property to another property in Kivy?
  • Python extracting specific line in text file
  • How to implement n-body simulation with pymunk?
  • Python / matplotlib: print to resolution and without white space / borders / margins
  • Sum up the second value from one dictionary with all values from another dictionary
  • Robot Framework: Open a chrome browser without launching URL
  • Generate inline Bokeh scatterplots in Jupyter using a for loop
  • Group list of dictionaries python
  • Efficient way to apply multiple Boolean mask to set values in a column using pandas
  • Lazy evaluation of a Python dictionary
  • id of xpath is getting changed every time in selenium python 2.7 chrome
  • Matplotlib RuntimeWarning displaying a 3D plot
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org