Intersection of the C ++ line and plane

Source: Internet
Author: User

The intersection between the midline and the plane of a three-dimensional space is calculated using the vector calculation method, which is easy to understand. The OpenGL version I have referred to is straightforward.

Last pointCodeFor reference only

// PL Ray endpoint, pp plane point, e-ray unit vector, q plane information, P return intersection void ctriobject: calculatelineandplane (double pl [], double PP [], double E [], double * q, double * P) {double T; if (Q [1] * E [0] + Q [2] * E [1] + Q [3] * E [2]) = 0) {return;} else {T = (Q [1] * (PP [0]-pl [0]) + Q [2] * (PP [1]-pl [1]) + Q [3] * PP [2]) /(Q [1] * E [0] + Q [2] * E [1] + Q [3] * E [2]); P [0] = pl [0] + E [0] * t; P [1] = pl [1] + E [1] * t; P [2] = E [2] * t ;}}

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.