0

I have an NSBezierPath which is shows a visual description of some data. As such, I not only need to see the NSBezierPath visually, I also would like to query it at any x value to determine the corresponding y value(s).

In short, I would like to use the NSBezierPath (or any BezierPath) in my view, and in my model. I want the view and the model to use the same formula, so that the visual representation of the model is accurate.

I recognize that in providing an x value, the number of corresponding y values could be zero, one, or many. Currently, I do not see any way to get individual points out of the NSBezier path, except for the control points and endpoints. I want to be able to query the Bezier Path for its value at ANY location, not just critical points.

Marcy
  • 4,611
  • 2
  • 34
  • 52
dmann200
  • 529
  • 4
  • 11
  • 1
    Worst case: https://pomax.github.io/bezierinfo/#yforx - that is: you first find the time parameter(s) belonging to that `x` value, because once you have `t` values, it's trivial to get the corresponding `B(t) = (x,y)` values – Mike 'Pomax' Kamermans May 27 '20 at 21:41
  • 1
    The difficulty in doing this is precisely why using a bezier path as part of a model isn't a good idea. In any case, you say the path "shows a visual description of some data". That "some data" should be your model. – Ken Thomases May 27 '20 at 23:48
  • While my model only stores the same critical values as the NSBezierPath uses, I still need to have one common interpolation strategy so that when I query the model to say "what is the value at time t?" that correlates visually to what is shown in the view. – dmann200 May 28 '20 at 00:12

0 Answers0