编辑:我用答案更新了程序,效果很好!
我正在制作一个程序(随意尝试),让用户绘制多边形,然后进行三角测量.他们可以单击添加顶点并按Enter键进行三角测量.无论如何,算法工作正常,只要我告诉它是否以顺时针或逆时针方式绘制点(现在我将它设置为仅与顺时针多边形一起工作).我一直试图弄清楚这几天,但不知道如何确定点是顺时针还是逆时针.尝试使用前面提到的程序绘制形状以获得更好的想法,您可以更好地体验我所说的内容,而不是尝试解释它.
以下是点的定义方式:
function Point(x, y) {
this.x = x;
this.y = y;
}
var vertices = [];
// Called on click
function addPoint(mouseX, mouseY) {
vertices.push(new Point(mouseX, mouseY));
}
Run Code Online (Sandbox Code Playgroud)
这是一个顺时针多边形的图像:

这是逆时针多边形的图像:

如果你能帮我弄清楚如何确定积分的"顺时针方向",我将非常感激!
假设我有一条线的坐标(25,35 45,65,30,85 - 它将是两部分线).我需要每帧以恒定的距离沿着那条线移动一个点(汽车).我怎样才能做到这一点?
我将在接下来的几个月里提出很多问题.对于我的九年级科学博览会项目,我想创建一个交通模拟器,以测试互连的交通信号灯是否可以增加交通流量.我有几个通用的问题,我需要帮助...
我不是在寻找具体的代码,只是很好的指针和资源来帮助我开始.任何帮助表示赞赏,C.Ruhl.
PS我只是在高中所以没有高级数学符号请:)
我正在写一个遗传算法,我打算从轮盘选择转到锦标赛选择,但我怀疑我的理解可能有缺陷.
如果我只选择人口中的n/2最佳解决方案,那么我的人口肯定会很快耗尽吗?
我对算法的理解是:
for(Member m in currentPopulation){
Member randomMember1 = random member of currentPopulation which is then removed from currentPopulation
Member randomMember2 = as above;
//Mutate and crossover
if(randomMember1.getScore() > randomMember2.getScore()){
nextGeneration.add(randomMember1);
} else {
nextGeneration.add(randomMember2);
}
}
Run Code Online (Sandbox Code Playgroud)
我理解正确吗?
我有两个描述神经网络结构的对象数组,如何将它们组合起来产生一个逼真的后代?"染色体"看起来像这样:
chromosome = [
[Node, Node, Node],
[Node, Node, Node, Node, Node],
[Node, Node, Node, Node],
[Node, Node, Node, Node, Node],
[Node, Node, Node, Node, Node, Node, Node],
[Node, Node, Node],
];
Run Code Online (Sandbox Code Playgroud)
示例节点:
Node {
nodesThatThisIsConnectedTo = [0, 2, 3, 5] // These numbers identify which nodes to collect output from in the preceding layer from based on their index number
weights = [0.34, 0.33, 0.76, -0.56] // These are the corresponding weights applied to the mentioned nodes
}
Run Code Online (Sandbox Code Playgroud) 假设我有一个网格,其中的线条连接顶点的方式可以将其拆分为四面体.是否有一个算法可以用来检测给定顶点和线条的四面体的存在?(即,如果网格带有连接线,则输出一组具有相同形状和体积的四面体.)
编辑:不允许四面体交叉.
如果我有代码:
function RandomObjectThatIsntNamedObjectWhichIOriginallyNamedObjectOnAccident() {
this.foo = 0;
this.bar = function () {
this.naba = function () {
//How do I reference foo here?
}
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个控制人工草食动物的人工神经网络.输入是最接近的植物的大小和方向,最接近的配偶的大小和方向,以及草食动物的健康.输出是运动矢量(方向和幅度).如果通过遗传算法训练,是否有必要使用偏见?
artificial-intelligence artificial-life neural-network genetic-algorithm
假设我有一些由面和线连接的任意点集,以便制作一个封闭的多面体。有没有什么算法可以把这样的网格划分成一组四面体?
这是圆圈类:
public class Circle {
private double radius;
private double x;
private double y;
}
Run Code Online (Sandbox Code Playgroud)
如何判断此类(圆圈)中的两个对象是否发生碰撞?
PS你能使用避免取平方根的方法吗?
让我们说我有阵列:
int[] taco = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
Run Code Online (Sandbox Code Playgroud)
如何根据索引将元素移动到前面?例:
将元素taco [5]移动到前面应该产生这个:
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
// becomes
{5, 0, 1, 2, 3, 4, 6, 7, 8, 9}
Run Code Online (Sandbox Code Playgroud)
编辑:如果整数是对象,它会有所作为吗?