MeshCat.jl icon indicating copy to clipboard operation
MeshCat.jl copied to clipboard

Plotting curves

Open evcastelani opened this issue 5 years ago • 1 comments

First of all, MeshCat.jl is awesome! Great job! Second, if possible, I would like some tip to build a curve in R^3. For example, considering the equation (x-1)^2+(y-1)^2+z^2-4+5x-3y-z-2 x=0 (I know, it is the intersection of a sphere with a plan) or any other implicit curve, how can I plot this curve?

evcastelani avatar Jul 12 '20 14:07 evcastelani

I am not sure how to go about converting an implicit curve (like the one you wrote) into a set of points that you can then use for rendering the curve in MeshCat.

But here's an example of how to render an explicit function, e.g., f(x) = x^2:

using Colors
using MeshCat

vis = Visualizer()
open(vis)

f(x) = x^2

points = [[x, 0, f(x)] for x = -1:0.1:1]

pointcloud = PointCloud(points)
material = LineBasicMaterial(color=colorant"yellow", linewidth=2)
setobject!(vis["line"], Object(pointcloud, material, "Line"))

image

ferrolho avatar May 22 '23 23:05 ferrolho