Solved

java 3d bounds

Posted on 2011-03-02
2
659 Views
Last Modified: 2013-12-26
Hi everyone,
I'm new to this forum and new to Java 3d. I've been trying to solve my problem for days but I can't find a solution! I am creating a mind map(like a graph) and I have problem with intersection. I use spheres for the nodes and cylinders as the links between them. I have a  function where it calculates the position of the node(each node can have 18 children around it) and how to position the cylinder(edge). I have added boundingspheres to the nodes to check for intersections and it works fine but I'm trying to add boundingboxes to the links and get the wrong results. Can anyone tell me how to add a boundingbox around a cylinder? Oh I have to check for intersections before I add the nodes and links to the scene so I have to check the boundingbox depending on the position that the cylinder will have afterwards... I hope I make sense...


0
Comment
Question by:aquarius4291
2 Comments
 
LVL 25

Accepted Solution

by:
InteractiveMind earned 250 total points
ID: 35075150
I personally would not add a bounding box to the cylinders. It is fairly straightforward to check for cylinder-cylinder and cylinder-sphere intersections:

Cylinder-sphere
------------------------
Let the cylinder start at x, be of radius r, length L, direction d.
Let the sphere be at o, radius R.
Find the shortest distance between the point o and the line x+t*d, as outlined here:
http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html
Then if the shortest distance is greater than (r+R) then they do NOT intersect.
Otherwise, if the closest point is for t<L, then they DO intersect.

Cylinder-cylinder
-------------------------
Exactly the same concept.
Suppose cylinder A begins at x_A, is of length L_A, has radius r_A, and points in the direction d_A.
Similarly for cylinder B.
Then compute the shortest distance between the axes of each cylinder, as explained here:
http://www.softsurfer.com/Archive/algorithm_0106/algorithm_0106.htm (It's just one equation)
Is this distance greater than (r_A+r_B)? If so, then they do NOT intersect.
Otherwise, suppose the point on the axis of A which is closest to the axis of B is x_A+t*d_A, where t is a parameter. Then if t<L then the cylinders DO intersect.

Does that make sense?
0
 

Author Comment

by:aquarius4291
ID: 35081874
It does make sense but doesn't that mean that for every new node I will have to check for intersection between the new one and all the others that already exist? I'm currently using bounds.intersect and I give an array of all the bounds as a parameter. I assume that a for loop happens 'behind the scenes' but isn't it easier this way? Also even though I do save the coordinates for each object, the cylinders are rotated in different ways which makes it a bit difficult to calculate the area each one covers.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now