我正在研究一些渲染图形,我有一个这样的模型,我正在使用Java画布工具和窗口,否则独立编写.
所有零件都是矩形多边形或线段.正如在此模型中发生的那样,所有多边形部分都与x,y或z平面对齐,xy原点从图片中模型的前角开始运行.(可以通过仔细观察它们看起来如何拼接在一起来辨别侧面的矩形细分 - 但是这里没有解决这个神器的问题)
我还没有找到一种获得干净深度排序的技术,这个技术基于最远的顶点.我尝试了一些天真的技术,他们都有各种各样的文物.我注意到二进制空间分区和Newell的算法没有钻研,但有一种感觉,在这种情况下应该有一个更简单的方法,特别是在所有部件都是正确对齐并平行于轴的条件下.关于它的方法的任何提示赞赏
更新
我想出了这个可能会有所改变的想法
给定平面面对约束,存在6种可能的关系,(xx平面),(xy平面),(xz平面),(yy平面),(yz平面)和(zz平面).
如果两个多边形共享同一平面很容易排序,其他3个组合如上图所示(xy在xz上),(xy在yz上)和(xz在yz上),可能出现不同的深度顺序.
鉴于P1 = polygon1和P2 = polygon2,我认为我的比较条件可能是这样的
if (P1 == xy_plane) return min(P1.z, P2.z)
if (P2 == xy_plane) return min(P2.z, P1.z)
if (P1 == xz_plane) return min(P1.y, P2.y)
if (P2 == xz_plane) return min(P2.y, P1.y)
Run Code Online (Sandbox Code Playgroud)
P1或P2必须位于前两个平面之一,因此对于问题陈述应该足够,需要确认这种方法是否有效
UPDATE2
我在上面的想法上取得了一些进展,看起来多边形匹配的排序正在做一些有趣的事情,它已经部分工作了,我说它看起来很简单,但是,......好吧,我希望你认为它是可以的告诉我我需要做什么.
沿着上面的路线,首先与我的假设相反,同一平面上的多边形不是微不足道的,它们可以有几种不同的配置; 平行且不共享另一个轴,例如在前两个轴中,或平行且在同一平面上.这有时意味着他们不关心他们排序的轴(用于成对比较),(并且说明了这种追求的更深层次).
设置一系列条件语句,不管是什么,与上面的建议一致,具有蛮力的味道和一系列广泛的"if-else",我想我最终找到了一个正确的成对多边形到多边形比较因此,在这个概念中,如果主体或其他主体更接近,则可以肯定地说出来.
在这里模拟模型的一个方面,设法产生看起来非常有说服力的东西.整个过程总体感觉接近锁定,但试图摆脱一些最终的错位以某种方式挑衅,因为旧的物理trivias固定一方另一方总是被打破.
我正在编译并运行一些名为Structr(https://github.com/structr/structr)的项目的源代码.我可以使用maven mvn命令正确运行程序,但不能使用JVM java命令.
编译步骤顺利 maven clean install -DskipTests
在运行前端(在structr-ui目录中)时,如果使用maven exec:exec但是失败则进展顺利java -cp target/lib/*;target/structr-ui-0.8.2.jar org.structr.Ui.我有一些指示堆栈跟踪java.lang.NoClassDefFoundError的org.structr.core.entity.AbstractNode和org.structr.core.EntityContext.我觉得奇怪的是我们拥有的exec条目中的maven pom.xml文件
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>-server</argument>
<argument>-Dfile.encoding=utf-8</argument>
<argument>-XX:+UseNUMA</argument>
<argument>-Xms1g</argument>
<argument>-Xmx1g</argument>
<argument>-classpath</argument>
<argument>target/lib/*;target/structr-ui-0.8.2.jar</argument>
<argument>org.structr.Ui</argument>
</arguments>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
整个pom.xml读取
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.structr</groupId>
<artifactId>structr</artifactId>
<version>0.8.2</version>
</parent>
<groupId>org.structr</groupId>
<artifactId>structr-ui</artifactId>
<packaging>jar</packaging>
<version>0.8.2</version>
<name>structr-ui</name>
<description>Structr is an open source framework based on the popular Neo4j graph database.</description>
<developers>
<developer>
<name>Axel …Run Code Online (Sandbox Code Playgroud) 我正在学习流表达式并尝试使用它们来构造一个 2D 布尔数组,所有值都设置为 true。就像是:
boolean[][] bool_array = [stream expression returning a
2D array boolean[h][w], all values set to true]
Run Code Online (Sandbox Code Playgroud)
这是可能的,表达式是什么?
我知道int[][]可以使用流创建数组,例如
int h=5;
int w=8;
int[][] int_array = IntStream.range(0,h).mapToObj(i->IntStream.range(0,w).
map(j->1).toArray()).toArray(int[][]::new);
Run Code Online (Sandbox Code Playgroud)
返回一个int[5][8]充满的。但试图让它为之工作boolean[][]
boolean[][] bool_array = IntStream.range(0,h).mapToObj(i->IntStream.range(0,w).
mapToObj(j->true).toArray()).toArray(boolean[][]::new);
Run Code Online (Sandbox Code Playgroud)
抛出一个ArrayStoreException.
我正在使用Ebean进行对象映射,并且我已经创建了我的SQL表
create table company (
id int auto_increment not null primary key,
name varchar(100)
);
create table employee (
id int auto_increment not null primary key,
name varchar(100) not null,
company_id int not null,
constraint foreign key (company_id) references company (id)
on delete restrict on update restrict
);
Run Code Online (Sandbox Code Playgroud)
这是Ebean公司的模型
import javax.persistence.Entity;
import javax.persistence.Id;
import com.avaje.ebean.Model;
@Entity
public class Company extends Model
{
@Id
public Integer id;
public String name;
}
Run Code Online (Sandbox Code Playgroud)
和员工模型
@Entity
public class Employee extends Model
{
@Id
public …Run Code Online (Sandbox Code Playgroud) 我在 C# .Net 5.0,Visual Studio 中工作。我正在格式化整数以像这样填充零
$"{-1:d04}"
$"{1:d04}"
Run Code Online (Sandbox Code Playgroud)
格式化正数和负数给出不同长度的结果字符串
-0001
0001
Run Code Online (Sandbox Code Playgroud)
我需要我的数字长度相同(即本例中的结果应该是字符串"-001"和"0001"),是否存在任何格式模式来实现这一点?