在本文中,我们将带你了解计算Shapely几何对象的成对距离在这篇文章中,同时我们还将给您一些技巧,以帮助您实现更有效的css–如何在旋转和缩放后计算SVG对象的坐标?、numpymeshgrid到S
在本文中,我们将带你了解计算Shapely几何对象的成对距离在这篇文章中,同时我们还将给您一些技巧,以帮助您实现更有效的css – 如何在旋转和缩放后计算SVG对象的坐标?、numpy meshgrid到Shapely多边形、OpenSCAD通过循环快速复制几何对象、OpenSCAD:几何对象与修剪扩展库。
本文目录一览:- 计算Shapely几何对象的成对距离
- css – 如何在旋转和缩放后计算SVG对象的坐标?
- numpy meshgrid到Shapely多边形
- OpenSCAD通过循环快速复制几何对象
- OpenSCAD:几何对象与修剪扩展库
计算Shapely几何对象的成对距离
sklearn度量标准期望参数x
具有可转换为float的有效dtype。如果您看到源代码,它将在计算它们之间的距离之前将数组转换为float。
由于X由多边形对象组成,因此在将数组转换为float时会出错。
但是,您可以构建自己的pair_wise
函数,该函数以polygon array
和distance function
作为输入,并以distance matrix
作为输出。
代码:
import geopandas as gpd
from random import uniform
from shapely.geometry import Point
import numpy as np
# Define polygon to polygon distance callable
def poly_distance(poly1,poly2):
return poly1.distance(poly2)
# Make some points and buffer them into polygons
geoms = [Point(uniform(0,100),uniform(0,100)) for i in range(100)]
gdf = gpd.GeoDataFrame(geoms,columns=["geometry"],geometry="geometry")
gdf[gdf.geometry.name] = gdf.buffer(1)
X = gdf[gdf.geometry.name].to_numpy()
def pair_wise(x,function):
distance_matrix = []
for element in x:
distance_matrix.append([function(element,item) for item in x])
return np.array(distance_matrix)
pair_wise(X,poly_distance)
css – 如何在旋转和缩放后计算SVG对象的坐标?
有没有办法在旋转后计算SVG对象的结束坐标?
如果有人知道请帮我解决这个问题.
解决方法
You can select the object using d3 or jquery if you are using d3 the select in this way var rect = d3.select(selecteObject); if jquery then var rect = $(selecteObject); var newx = rect.node().getBBox().x; var newy = rect.node().getBBox().y; var neww = rect.node().getBBox().width; var newh = rect.node().getBBox().height; var endCodinatex = newx + neww; var endCodinatY = newy + newh;
numpy meshgrid到Shapely多边形
我正在尝试创建一个numpy
meshgrid并将其转换为Shapely多边形。我可以用一种非常蛮力的方法解决这个问题,但是感觉必须要有一个很好的技巧才能完成,但是我还没有提出。
这使我获得了点网格(假定在Jupyter中运行)-
import numpy as np
from matplotlib import pyplot
fig = pyplot.figure(figsize=(10,10))
ax = fig.add_subplot(111,aspect='equal')
x,y = np.mgrid[-5:-1:8j,1:5:8j]
ax.plot(x,y,'o',color='#000000')
pyplot.show()
现在需要将所有这些点水平和垂直连接以形成Shapely多边形。我的第一个尝试是生成Shapely
MultiLineString来绘制垂直和水平线,然后对其执行多边形化操作。这导致仅创建了主要的外部多边形-
这是由于MultiLineString仅在外部多边形上包含了顶点。
我知道使用栅格和GDAL可能更合理,但是我的情况要求最终结果为Shapely多边形。
跟踪解决方案的任何帮助都将受到赞赏!
OpenSCAD通过循环快速复制几何对象
OpenSCAD支持变量和循环,从而可以快速复制出大量的几何对象并且按照递归的方式进行布局。
循环的变量可以是枚举、区间和矢量对象,循环体支持几何对象构建、坐标平移与旋转、交并差等操作。
循环的递归变量类型
Vector(矢量):
for (variable=<vector>) {
<do_something> - <variable> is assigned to each successive value in the vector
}
Range(区间、范围):
for (variable=<range>) {
<do_something>
}
Nested(嵌套) :
for ( variable1 = <range or vector>, variable2 = <range or vector> ) {
<do something, using both variables>
}
for 循环可以进行嵌套,就像普通程序一样。
使用枚举型矢量的循环
Usage example 1 - 通过vector的循环调用 | |
|
使用范围型变量的循环 |
Usage example 2a - 通过范围实现循环 | |
|
使用范围型给定步长的循环 |
Usage example 2b -指定步长和范围的循环 |
|
Usage example 3 - 通过矢量的循环 (旋转) | |
|
通过矢量数组的枚举型循环 |
Usage example 4 -矢量数组的循环(位移): | |
|
循环的嵌套和多变量 |
嵌套循环的例程
for (xpos=[0:3], ypos = [2,4,6]) // do twelve iterations, using each xpos with each ypos
translate([xpos*ypos, ypos, 0])
cube([0.5, 0.5, 0.5]);
循环的切割
所有的循环(包括枚举值、范围、矢量、矢量数组)都支持几何实体的 intersection 操作。
注意: intersection_for()
is a work around because of an issue that you cannot get the expected results using a combination of the standard for()
and intersection()
statements. The reason is that for()
do a implicit union()
of the contents.
参数
<loop variable name>
Name of the variable to use within the for loop.
Usage example 1 - 范围循环: | |
|
Intersection for使用示例: |
Usage example 2 - rotation : | |
|
OpenSCAD:几何对象与修剪扩展库
OpenSCAD Libraries
- General
- · BOSL
- · BOSL2
- · dotSCAD
- · NopSCADlib
- · UB.scad
- · Functional OpenSCAD
- · BOLTS
- Single Topic
- · Round Anything
- · Mark''s Enclosure Helper
- · funcutils
- · threads.scad Module
- · Smooth Primitives Library
- · Function Plotting Library
- · ClosePoints Library
- · Tray Library
- · YAPP Generator
- · STEMFIE Parts Library
General
BOSL
The Belfry OpenScad Library - A library of tools, shapes, and helpers to make OpenScad easier to use.
- » Library
- » Documentation
- » License: BSD-2-Clause
BOSL2 (beta)
Belfry OpenScad Library v2 - A library of tools, shapes, and helpers to make OpenScad easier to use.
- » Library
- » Documentation
- » Tutorials
- » License: BSD-2-Clause
dotSCAD
Reduce the burden of 3D modeling in mathematics.
- » Library
- » Documentation
- » License: LGPL-3.0-only
NopSCADlib
An ever expanding library of parts modelled in OpenSCAD useful for 3D printers and enclosures for electronics, etc.
- » Library
- » Documentation
- » License: GPL-3.0-or-later
UB.scad
This library is a full 3D printing workflow solution for OpenSCAD, bringing tools for modifying and generating 3D objects, view helpers and a selection of mechanical parts.
- » Library
- » Documentation
- » License: CC0-1.0
Functional OpenSCAD
Implementing OpenSCAD in OpenSCAD.
- » Library
- » Documentation
- » License: MIT
BOLTS
BOLTS is an Open Library of Technical Specifications.
- » Library
- » Documentation
- » License: LGPL-2.1-or-later | GPL-3.0-only
Single Topic
Round Anything
Round-Anything is primarily a set of OpenSCAD utilities that help with rounding parts, but it also embodies a robust approach to developing OpenSCAD parts.
- » Library
- » Overview - A pragmatic approach to OpenSCAD design
- » Documentation - API reference and examples
- » License: MIT
Mark''s Enclosure Helper
A script for generating a two piece hinged box, with rounded corners, lid, interlocking rims, snap fit, magnet, or screw closures, and easy places for adding cutouts or additions to any face..
- » Library
- » Documentation
- » License: GPL-3.0-only
funcutils
This library is a collection of OpenSCAD functions for use with the function-literals feature. It is meant to provide algorithms and tools to help build efficient scripts using functional programming techniques in OpenSCAD.
- » Library
- » Documentation
- » License: CC0-1.0
OpenSCAD threads.scad Module
This is an efficient OpenSCAD threading library intended primarily to be used as a component in other designs. It supports metric compatible internal and external threads, auger threads, thread tapering, clearance holes, countersunk holes, recessed holes, hex bolts, nuts, washers, Phillips tips, and long rods which are extended with threaded joints. Whenever possible this complies with metric standards for the defaults of parameters, while providing overrides for many values.
- » Library
- » Documentation
- » License: CC0-1.0
OpenSCAD Smooth Primitives Library
This library is a collection of some smooth primitives, i.e. having specified rounded edges, for use in other designs. It''s not a comprehensive collection, but a useful set.
- » Library
- » Documentation
- » License: CC0-1.0
OpenSCAD Function Plotting Library
This is a general purpose function plotting library for OpenSCAD which will render functions with Cartesian coordinates (x & y input, z output), polar/cylindrical coordinates (r & angle input, z output), or axial coordinates (z & angle input, r output). This library is sufficiently flexible that it can be used for more than just plotting functions. As demonstrated in the included demo files, this can efficiently render ordinary objects with surfaces defined by mathematical functions.
- » Library
- » Documentation
- » License: CC0-1.0
OpenSCAD ClosePoints Library
This is a general purpose OpenSCAD library for easily creating diverse shapes by simply creating lists of points which trace out layers in an outline of the desired shape. The library consists of modules for creating polyhedrons from these lists of points, as well as functions to assist in specifying the points using transformations.
- » Library
- » Documentation
- » License: CC0-1.0
Tray Library
Allows the design of trays with optional subdivisions. Many different configuration options available. Designed to quickly create trays with different configurations, for efficient storing of parts, such as hardware, small tools, board game inserts, etc..
- » Library
- » Documentation
- » License: LGPL-3.0-or-later
Yet Another Parametric Projectbox generator
A generator for electronic project boxes, based on a definition of a PCB and lots of options for defining PCB standoffs and case cutouts.
- » Library
- » Documentation
- » License: MIT
STEMFIE Parts Library
OpenSCAD library to create parts for the STEMFIE project.
STEMFIE is a free educational construction-set toy you can download and make at home using a 3D printer. Each component is a part of a mechanical ecosystem of compatible shapes designed to interlock through various connections and fasteners.
- » STEMFIE project
- » Library
- » Documentation
- » License: GPL-3.0-or-later
今天关于计算Shapely几何对象的成对距离的介绍到此结束,谢谢您的阅读,有关css – 如何在旋转和缩放后计算SVG对象的坐标?、numpy meshgrid到Shapely多边形、OpenSCAD通过循环快速复制几何对象、OpenSCAD:几何对象与修剪扩展库等更多相关知识的信息可以在本站进行查询。
本文标签: