4 Knives cutting up to what part of a cube

Source: Internet
Author: User
Origin

Today by chance to see this problem, I figure out is 3 knife with plane 7, multiplied by 2 is 14. The result is that this is not the optimal, I can not think of the simulation of a bit. Numerical simulation calculation principle

Initialize 4 planes, generate 100 points to verify all the states and. Results for the source

import NumPy as NP import random as Rd # # #点的限制条件在1, in the range of the Cube def setP3 (): Return rd.uniform (0,1), rd.uniform (0,1), Rd.uniform (0,1) # # #生成平面; Incoming list (tuple) def SETPM (): M33 = Np.mat ([SetP3 (), setP3 (), setP3 ()]) return (M33. I) * (Np.mat ([1,1,1]).
        T) #判断点在面内1, or out-of-plane 0 def pdmp (m,p): A,b,c = m x, y, z = P flag = a*x + b*y + c*z-1 if (Flag > 0): return 0 return 1 #生成4个平面 and output 4 flat tuple def set4m (): Return [SETPM () for I in range (4)] # #判断点和各个面的状态和 def Setdl (PM 4, p): locat = 0 for I in range (4): Locat = locat + 2**i * PDMP (Pm4[i], p) return Locat # #随机选出100个点判断 The state of these points is set to Def Main (): ZT = [] pm4 = set4m () for I in range: P = setP3 () zt.append (Setdl (PM 4, p)) return Np.unique (ZT) print (max ([Len (Main ()) for I in range)) 

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.