如何計算一個長方體與其相鄰長方體的接觸面積 (How to calculate area of contact of one rectangular cuboid to its adjacent cuboids)


問題描述

如何計算一個長方體與其相鄰長方體的接觸面積 (How to calculate area of contact of one rectangular cuboid to its adjacent cuboids)

I'm trying to position different-sized rectangular cuboids next to each other such that the area of contact between those is maximized.

In a brute-force kind of way I'm searching for a possible position for each to be positioned cuboid in space which doesn't intersect with any other cuboids. I realized this using Java 3D's BoundingBox class where it's possible to check whether a given box intersects with a given collection of other boxes. Now I got many possible locations from which I need to choose the one with the highest area of contact to other boxes.

My problem is that I don't know how to calculate this area efficiently. A little example...

Box 1: lower left point x=0,y=0,z=0; upper right point x=10,y=10,z=10

Box 2: lower left point x=10,y=0,z=0; upper right point x=15,y=5,z=5

Box 3 has the same dimensions as Box 1 and should be positioned with maximum area of contact

In this example all positions where one side of Box 3 matches any except the right side of Box 1 (where Box 2 is) are optimal solutions.

I would be very glad if someone has an idea or even a solution. I'm also happy with free libraries if they are not too huge.

Thanks!


參考解法

方法 1:

Consider each potential pair of touching faces in turn.

Place box 2 anywhere in contact with box 1. You then recursively search. For each location you identify all the intersecting cuboids and then find minimum movement up, down, left and right that would prevent an intersection with one of those intersecting cuboids. This establishes four new places to search from. You then work out from these as well.

To clarify, if you are moving left, you find the rightmost left face of an intersecting cuboid and move so that face no longer intersects. Other cuboids will probably still intersect but we will recursively move away from them.

If there are no intersections, you have a stop location and you note the area and carry on searching.

If a move make it impossible to touch the original box, you don't explore further along that route.

For each face you can find that either no locations are possible, or there is at least one with a maximal are of contact for that face.

You then repeat the process for the other 5 faces.

(by letmaikSimon G.)

參考文件

  1. How to calculate area of contact of one rectangular cuboid to its adjacent cuboids (CC BY-SA 3.0/4.0)

#java #3d #area #java-3d






相關問題

電子郵件地址中帶有 + 字符的 Java 郵件 (Java mail with + character in email address)

如何快速原型化 Java 代碼? (How to quickly prototype Java code?)

如何使用 Maven 在目標(SVN-)服務器上創建 Javadoc? (How to create Javadoc on the target (SVN-) server using Maven?)

為什麼檢查二叉樹有效性的解決方案不起作用? (Why the solution for checking the validity of binary tree is not working?)

Selenium webdriver通過第一個數字找到texy (Selenium webdriver find texy by first digits)

setOnClickListener 沒有在圖像視圖上被調用 (setOnClickListener is not getting called on image view)

繪製多邊形:找不到錯誤 (Drawing Polygon : unable to find error)

半透明 JButton:對像出現在背景中 (Semi-Transparent JButton: Objects appear in Background)

比較同一數組的元素 (Compare elements of the same array)

Java 屏幕截圖小程序 (Java screen capture applet)

Minecraft 1.8.9 Forge Modding 的Java 開發工具包,需要什麼JDK/JRE,代碼是否正確? (Java Development Kit with Minecraft 1.8.9 Forge Modding, What JDK/JRE Is Needed, Is Code Correct?)

java while (resultset.next()) 不返回同一列中的所有數據 (java while (resultset.next()) does not return all data in the same column)







留言討論