10
$\begingroup$

I'm trying to model a snake, which I can do very basically if I do it manually, first getting the x,y coordinates from image tools, then guessing z coordinates (using @J. M.'s ennui 's plotTube function (though it won't seem to accept Piecewise):

pts2 = {{1, 5.5, 2}, {2, 5.5, 2}, {3, 6, 1}, {4, 6, 0}, {5, 
6, -2}, {4, 7, 2}, {5, 7, 3}, {7, 7, 2}, {5, 5, 1}, {2, 4, 0}, {4,
 3, -2}, {6, 6, -3}, {5, 8, 1}, {6, 9, 4}, {9, 7, 3}, {7, 4, 
0}, {8, 3, -1}, {10, 4, -2}, {9, 5, 0}, {9, 3, 2}, {8, 1, 0}, {6, 
2, 0}, {5, 2, 0}};
c1 = RGBColor[#/255, #2/255, #3/255] & @@ {142, 189, 61};
c2 = RGBColor[#/255, #2/255, #3/255] & @@ {208, 218, 61};
g = Graphics[{c1, Thickness[.5], Line@{{0, 0}, {1, 0}}}, 
Background -> c2, PlotRangePadding -> 0];
f = BSplineFunction[pts2, SplineDegree -> 4];
Import["https://upload.wikimedia.org/wikipedia/en/5/5e/Trimeresurus_\salazar.jpg"]
Show[plotTube[
   f[t], (3 (1 - .1^5) + (t^.25 - .1^.25) (3 (1 - .1^5)/.1^.25)) circ@
    u, {t, 0, .1}, {u, 0, 2 \[Pi]}, PlotPoints -> 200, 
  ImageSize -> Medium, ViewPoint -> {1, -.2, 3}, 
  ViewVertical -> {.1, 1, 0}, Mesh -> False, Boxed -> False, 
  Axes -> False, PlotStyle -> Texture[g], 
  TextureCoordinateScaling -> True, 
  TextureCoordinateFunction -> Function[{x, y, a, b}, {a, 20 b}], 
  PlotRange -> All], 
 plotTube[f[t], 3 (1 - t^5) circ@u, {t, .1, 1}, {u, 0, 2 \[Pi]}, 
  PlotPoints -> 200, ImageSize -> Medium, ViewPoint -> {1, -.2, 3}, 
  ViewVertical -> {.1, 1, 0}, Mesh -> False, Boxed -> False, 
  Axes -> False, PlotStyle -> Texture[g], 
  TextureCoordinateScaling -> True, 
  TextureCoordinateFunction -> Function[{x, y, a, b}, {a, 180 b}], 
  PlotRange -> All], Background -> Black, PlotRange -> All]

But I'd really like MMA to suggest 3d coordinates from image detection tools. Tried all sorts, but manually was quickest for me, albeit basic.

$\endgroup$
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.