小编Pla*_*iac的帖子

mathematica如何实现这种动态图?

这是BBC动态图形.我想有可能在Mathematica中重现图形.

在此输入图像描述

在回答的过程中,我们将在MMA中看到一些迷人的图形技巧.这是在这里提出这个问题的唯一原因.

更新:

我刚刚检查过BBC使用简单的JavaScript来做到这一点.他们手动制作了静态图片,甚至没有使用基于Flash的事件处理.因此,所有图片都是静态实体,一旦我们点击一​​个国家,它就会生成一个独特的图像.对于其他国家,它显示其他图像.每个案例的单独图像可以通过PowerPoint,Visio甚至Photoshop生成.人们可以通过在浏览器中禁用JavaScript并重新加载页面来检查这一点.

我知道那些单张照片可以从MMA制作.一些答案显示了如何做到这一点的正确方向.所以我接受到目前为止最好的答案.

graphics wolfram-mathematica

5
推荐指数
1
解决办法
702
查看次数

保存CGAL alpha形状表面网格

我从未使用过CGAL,几乎没有C/C++经验.但是在Google之后,我设法使用visual studio 2010在Windows 7 64位机器上编译了示例"Alpha_shapes_3"(\ CGAL-4.1-beta1\examples\Alpha_shapes_3).

在此输入图像描述

现在,如果我们检查程序"ex_alpha_shapes_3"的源代码,我们会注意到一个名为"bunny_1000"的数据文件是红色点集群所在的红色.现在我的问题是如何更改源代码,以便在为给定点计算alpha形状之后,alpha形状的表面网格被保存/写入外部文件.它可以是多边形列表及其各自的3D顶点.我想这些多边形将定义alpha形状的表面网格.如果我能做到这一点,我可以在我熟悉的外部工具中看到alpha形状生成程序的输出.

我知道这很简单,但我对CGAL的知识知之甚少.

我知道你猜测有代码,但我再次粘贴完成.

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Alpha_shape_3.h>

#include <fstream>
#include <list>
#include <cassert>

typedef CGAL::Exact_predicates_inexact_constructions_kernel Gt;

typedef CGAL::Alpha_shape_vertex_base_3<Gt>          Vb;
typedef CGAL::Alpha_shape_cell_base_3<Gt>            Fb;
typedef CGAL::Triangulation_data_structure_3<Vb,Fb>  Tds;
typedef CGAL::Delaunay_triangulation_3<Gt,Tds>       Triangulation_3;
typedef CGAL::Alpha_shape_3<Triangulation_3>         Alpha_shape_3;

typedef Gt::Point_3                                  Point;
typedef Alpha_shape_3::Alpha_iterator               Alpha_iterator;

int main()
{
  std::list<Point> lp;

  //read input
  std::ifstream is("./data/bunny_1000");
  int n;
  is >> n;
  std::cout << "Reading " << n << " points " << std::endl;
  Point p;
  for( ; n>0 ; n--)    {
    is …
Run Code Online (Sandbox Code Playgroud)

c++ 3d geometry mesh cgal

5
推荐指数
1
解决办法
2039
查看次数

如何将TetGen用于这个简单的3D几何体

以下是定义我的简单3D几何的点.

datN = {{{-0.47150460764747554`, 0.29559274991660417`, 
 0.010131794240974218`}, {-0.4762714873728534`, 
 0.2955927499166042`, 
 0.010567957416020535`}, {-0.4835042628911566`, 
 0.29559274991660417`, 
 0.01066658601048008`}, {-0.49133736140975415`, 
 0.29559274991660417`, 
 0.01010572204377315`}, {-0.4974365622729896`, 
 0.29559274991660417`, 
 0.009602808597554033`}, {-0.4999590574180981`, 
 0.2955927499166041`, 
 0.010150149141898643`}, {-0.497870343592127`, 
 0.2955927499166042`, 
 0.011728012221066566`}, {-0.491634397829927`, 
 0.2955927499166041`, 
 0.013089897457762985`}, {-0.4834169387190052`, 
 0.2955927499166042`, 
 0.013009607974106477`}, {-0.47609963350102275`, 
 0.2955927499166043`, 
 0.011622413291940486`}, {-0.471504606936728`, 
 0.2955927499166041`, 
 0.010131794240974216`}}, {{-0.5619323339485054`, 
 0.13709660728856332`, 
 0.010131794240974218`}, {-0.5878076066290028`, 
 0.13709660728856335`, 
 0.01249934738636439`}, {-0.6270680976744502`, 
 0.13709660728856332`, 
 0.0130347168361427`}, {-0.6695872237650179`, 
 0.13709660728856332`, 
 0.00999027080199048`}, {-0.7026945171227986`, 
 0.13709660728856332`, 
 0.007260388089336815`}, {-0.7163869644835803`, 
 0.13709660728856332`, 
 0.010231427144215837`}, {-0.705049141229765`, 
 0.13709660728856338`, 
 0.018796282936276536`}, {-0.6711995779276564`, 
 0.13709660728856332`, 
 0.02618878157043711`}, {-0.6265940901692914`, 
 0.13709660728856332`, 
 0.02575295931296998`}, {-0.5868747603960375`, 
 0.13709660728856335`, 
 0.018223077560156144`}, {-0.5619323300904714`, 
 0.1370966072885633`, 0.010131794240974216`}}};
Run Code Online (Sandbox Code Playgroud)

现在我们准备facet和vertices

pt = Flatten[{datN[[1]], datN[[2]]}, 1];
facets = Join[{{Flatten@Map[Position[pt, #] &, …
Run Code Online (Sandbox Code Playgroud)

3d wolfram-mathematica tetgen

3
推荐指数
1
解决办法
635
查看次数

Mathematica的编程挑战

我正在与Mathematica连接外部程序.我正在为外部程序创建一个输入文件.它将几何数据从Mathematica生成的图形转换为预定义的格式.这是一个几何示例.

图1

图1

可以在Mathematica中以多种方式描述几何体.一种费力的方法如下.

dat={{1.,-1.,0.},{0.,-1.,0.5},{0.,-1.,-0.5},{1.,-0.3333,0.},{0.,-0.3333,0.5},
{0.,-0.3333,-0.5},{1.,0.3333,0.},{0.,0.3333,0.5},{0.,0.3333,-0.5},{1.,1.,0.},
{0.,1.,0.5},{0.,1.,-0.5},{10.,-1.,0.},{10.,-0.3333,0.},{10.,0.3333,0.},{10.,1.,0.}};

Show[ListPointPlot3D[dat,PlotStyle->{{Red,PointSize[Large]}}],Graphics3D[{Opacity[.8],
Cyan,GraphicsComplex[dat,Polygon[{{1,2,5,4},{1,3,6,4},{2,3,6,5},{4,5,8,7},{4,6,9,7},
{5,6,9,8},{7,8,11,10},{7,9,12,10},{8,9,12,11},{1,2,3},{10,12,11},{1,4,14,13},
{4,7,15,14},{7,10,16,15}}]]}],AspectRatio->GoldenRatio]
Run Code Online (Sandbox Code Playgroud)

这将以GraphicsComplexMMA格式生成所需的3D几何体. 在此输入图像描述

此几何体被描述为我的外部程序的以下输入文件.

# GEOMETRY
# x y z [m]
NODES 16
1. -1. 0.
0. -1. 0.5
0. -1. -0.5
1. -0.3333 0.
0. -0.3333 0.50. -0.3333 -0.5
1. 0.3333 0.
0. 0.3333 0.5
0. 0.3333 -0.5
1. 1. 0.
0. 1. 0.5
0. 1. -0.5
10. -1. 0.
10. -0.3333 0.
10. 0.3333 0.
10. 1. -0.
# type node_id1 node_id2 node_id3 node_id4  elem_id1 elem_id2 …
Run Code Online (Sandbox Code Playgroud)

geometry wolfram-mathematica input cad computational-geometry

1
推荐指数
1
解决办法
561
查看次数

如何在特殊曲面网格中对边进行排序

这是一个功能,使用了几天前我问过的问题答案的建议.让我们在Mathematica中创建一个Graphics3D对象.我从这里使用这个3D几何数据.

cd = Import[NotebookDirectory[] <> "withwake.obj"];
vertices = cd[[1, 2, 1]];
polygons = Flatten[cd[[1, 2, 2, 1]] /. Polygon -> List, 2];
Graphics3D[GraphicsComplex[vertices, Polygon[polygons]]]
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

对于每个多边形,我们创建一个指向其顶点的数字列表,然后是指向每个边连接到的多边形的数字.重要的是要注意表面正常; 定义面板的节点顺序应为逆时针.通过右手规则,如果手指弯曲以跟随编号,拇指将显示应指向"向外"几何的法线向量.

如果Graphics3D对象中的所有多边形都是三角形,则此函数会创建此类列表.

EdgeSorting[vertices_, polygons_] := 
Block[{triangleEdges, singleEdges, edgesNeighbors, relations, n, n1,
 n2, trires, triangleNeigbours, TriangleMaker, polygonArea, tring},
(*Split every triangle in 3 edges,with nodes in each edge sorted*)   
triangleEdges = (Sort /@ Subsets[#, {2}]) & /@ polygons;
(*Generate a list of edges*)
singleEdges = Union[Flatten[triangleEdges, 1]];
(*Define a function …
Run Code Online (Sandbox Code Playgroud)

wolfram-mathematica mesh

0
推荐指数
1
解决办法
579
查看次数