2

I have been stuck on a chapter for a while now and I thought I might ask help on here.

I'm making a tree generator script for Maya (3D modelling software) with Python Tree in Maya viewport, and currently I want the branches to bend along their neighbors. For each branch class object I know:

  1. Its local and world rotation
  2. Its end and start point in local and world space.
  3. Its parent and children branches
  4. Indexes in 2D Array (Branches are generated per button press and the result list is being added to the sets list).

Based on the average children data and the parent data I want to add 1 In-between points to each curve that is being placed so that my branches bend nicely along their path. I would also have to pay attention to end and tip branches. To summarize my problem I made a little GIF for you. Provided GIF file

I'm looking for a mathematical implementation that I can easily translate to my project. My question is close to this solved problem, except that my problem would require a more manual implementation.

Mike 'Pomax' Kamermans
  • 49,297
  • 16
  • 112
  • 153
TristanG
  • 23
  • 5
  • Many answers suggests Bezier curves there https://math.stackexchange.com/search?q=curve+points+smooth – nicolallias May 21 '19 at 12:16
  • Cubic spline interpolation is a subset of bezier – Mad Physicist May 22 '19 at 03:27
  • One option would be to make that "smooth curve" from your GIF using catmull-rom curves, then (because they're the same curve, just a different representation) "convert" each segment [into a Bezier curve](https://pomax.github.io/bezierinfo/#catmullconv) and then compute what the point on that curve at `t=0.5` is. Now you have your new "extra points between each point". But you could also ignore the "curve building" entirely and just look at your "result" image, and determine what _linear properties_ you can exploit to find, roughly, those points. – Mike 'Pomax' Kamermans May 22 '19 at 03:29
  • I'm sorry it is hard to find my way through those well defined but over informative docs, so I would really appreciate if you could please give me an example in Y-up space of a start branch from origin to (0, 10, 0) with children being connected and ending at a: (-2, 17, -0.5) , b:(2, 17, -0.5) and lets just say for simplicity a and b have both 1child shifted in the y axis +5, so a2(-2, 22, -0.5), b2(2, 22, -0.5). So we have 5 branches being able to explain all my problems. Strong thumbs up for the help! – TristanG May 23 '19 at 05:35

0 Answers0