• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Aug 25th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. // C++ implementation​​​​​​‌​​​‌​​​‌​​‌‌​‌​‌​‌​​​​​​ below
2. #include "math.h"
3.
4. struct Vector
5. {
6.     // Extend this struct as you see fit
7.
8.     Vector(double inX, double inY, double inZ)
9.     : x(inX), y(inY), z(inZ) {}
10.
11.     Vector() : Vector(0.0, 0.0, 0.0) {}
12.
13.     double x;
14.     double y;
15.     double z;
16. };
17.
18. typedef Vector Point;
19.
20. struct Plane
21. {
22.     Point origin;
23.     Vector dirrection1;
24.     Vector dirrection2;
25. };
26.
27. // Vector norm() {
28.
29. // }
30.
31. //vec - falling vector
32. bool GetReflected(const Vector& vec, const Plane& plane, Vector *reflected )
33. {
34.     // length of vec
35.     //sqrt(vec.x * vec.x + vec.y * vec.x + vec.z);
36.     //plane 1, plane 2
37.     Vector n;
38.     n.x = plane.dirrection1.y * plane.dirrection2.z  - plane.dirrection1.z * plane.dirrection2.y;
39.     n.y = plane.dirrection1.z * plane.dirrection2.x  - plane.dirrection1.x * plane.dirrection2.z;
40.     n.z = plane.dirrection1.x * plane.dirrection2.y  - plane.dirrection1.y * plane.dirrection2.x;
41.
42.     Vector n2;
43.     n2.x = 2*n.x;
44.     n2.y = 2*n.y;
45.     n2.z = 2*n.z;
46.
47.     //I x N
48.     Vector in;
49.
50.     in.x = vec.y * n2.z - vec.z * n2.y;
51.     in.y = vec.z * n2.x - vec.x * n2.z;
52.     in.z = vec.x * n2.y - vec.y * n2.x;
53.
54.     //2 * (I x N)
55.
56.     Vector R;
57.     R.x = vec.x - in.x;
58.     R.y = vec.y - in.y;
59.     R.z = vec.z - in.z;
60.
61.
62.     if (abs(R.x) == abs(vec.x)) return true;
63.
64.
65.     return false;
66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top
{"ft_lang_label":"__label__en","ft_lang_prob":0.53554404,"math_prob":0.9805082,"size":1541,"snap":"2019-35-2019-39","text_gpt3_token_len":520,"char_repetition_ratio":0.20429409,"word_repetition_ratio":0.0,"special_character_ratio":0.39584684,"punctuation_ratio":0.29765013,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9967477,"pos_list":[0,1,2,3,4,5,6,7,8,9,10],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-09-16T15:29:04Z\",\"WARC-Record-ID\":\"<urn:uuid:af5f4c12-c277-456f-8953-79c930207364>\",\"Content-Length\":\"29118\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:6993d89a-c2d2-4ade-8647-d3e7afcc6698>\",\"WARC-Concurrent-To\":\"<urn:uuid:3605012d-e495-49ab-a404-587261e1f601>\",\"WARC-IP-Address\":\"104.20.209.21\",\"WARC-Target-URI\":\"https://pastebin.com/sNS5uX2a\",\"WARC-Payload-Digest\":\"sha1:VK2J2PUDNWKHF66UQ56QGETHHDBIWWSZ\",\"WARC-Block-Digest\":\"sha1:RXCPEKI5ZU4BFVZ24X5RW7VWM6DR4BFN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-39/CC-MAIN-2019-39_segments_1568514572744.7_warc_CC-MAIN-20190916135948-20190916161948-00391.warc.gz\"}"}