Jump to content

merging/updating curve3


Mark Bufton
 Share

Recommended Posts

Hi guys,

Rather a technical question I'm afraid and one that I do have a functional solution to, but wanted to take the opportunity to learn something new.

I'm attempting to create the deck of a ship (the Titanic) from blueprints, using a curve3 object to create the outline of the decks (eventually using it to create path points for a polygon mesh/extruded shape, but simply used as line paths for the time being). This works perfectly fine, of course, as the deck plans are completely flat - using the X and Z co-ordinates (in my case) of the curve3 I can match the outline of the decks with reasonable precision.

A ship, however, doesn't tend to have flat decks - Titanic being no exception. The decks are curved upwards both forward and aft. One (almost) solution being to create an additional curve depicting the deck on a side (profile) blueprint (containing the same number of points as the aforementioned deck outline).

I have written functions to extract the x, y and z points of any given curve3 path, and could pass the x and z data from the deck curve, and the y data from the side profile curve, as arguments to my own custom curve. This would work in theory, if both curves were identical - then the x co-ordinates of the side profile would match perfectly the x co-ordinates of the deck plan's curve.

Where the poop deck, for instance, curves around sharply at the stern, the x co-ordinates of the deck outline will get considerably closer together, whereas they won't do so on the deck profile - using my 'solution' would likely result in a very warped deck.

My solution to the problem is a simple one - simply line up the two plans and visually adjust the y input of the start, end and control points of the bezier curve function (depicting the deck outline) to incorporate the curve of the deck - which is gentle enough to achieve easily.

My curious nature tends to get the better of me, as you all probably know, and leads me to ponder if there is a way to programatically get the x, y or z co-ordinates at any given point of the curve3? Take a simple curve from vector3(10,0,-10) to vector3(50,0,0) - if, for example, I wanted to know the value of z at x:31.265, am I able to get that or calculate that programatically without being a mathematical genius or including a massive number of points and searching the path array for the nearest value?

titanicComplete.jpg

genarr.gif

Link to comment
Share on other sites

http://doc.babylonjs.com/how_to/how_to_use_curve3

Unfortunately, there's no way to get a value from a curve at some distance or a given x value. Why ? because, despite it's called a "curve", it's actually a series of points (Vector3) linked by straight linear segments. All these tiny segments rendered together are an approximation of the real mathematical curve.

So given some x value, you could maybe get the nearest surrounding points V1, V2 and interpolate the right y on the line V1V2. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...