English 中文(简体)
如何使用轴作为 HINGE 在 3 位空间旋转矩形?
原标题:How to rotate a rectangle in 3d space using an axis as a HINGE?

我期待用数学或算法计算 旋转一个以 HINGE 形为固定轴的矩形。如下图所示。

我有4个矩形脊椎的(x,y)位置, 并且源头是矩形的中心, 所以想要的算法会将我原来的形状的顶部 投射到渴望形状的顶部。 (请见下文的图像)

但我需要用像.Net或JAVA这样的高层次编程语言,

<强> 请帮助我使用任何想法或参考或比所有源代码或算法更好的方法。

""https://i.sstatic.net/EkYcy.png" alt="此处输入图像描述"/ >

提前感谢您的高质量时间。

最佳回答
问题回答

从我的经验来看,在用两个维度工作时,我发现一个叫 process 的极好工具取得了巨大的成功。处理是爪哇编程语言的延伸,具体针对任何事物的可视化,从数据结构到恐吓物理模拟。从你提供的有用的图形,我假设你想在任何特定时间将一个结构围绕一个点或轴旋转。看看具有丰富特性的 API 引用, 处理报价(我是一个新用户, 不幸我无法将两个项目链接到 API 引用下面) 。 它们具有旋转和旋转点的独特功能。 但是, 它不会在指定点周围旋转结构, 而是旋转整个屏幕和它包含的每部分。 例如, 如果您想要将源( 0,0)周围的一切旋转45度, 它会简单到 :

void setup()
{
  size(200, 200); // Set the size of the screen to 200 x 200 pixels
  background(255); // Set the background to white
  smooth(); // Smooth the edges of the rectangles
  fill(192); // Fill the rectangle with a light gray
  noStroke(); // No black border on rectangle
  rect(40, 40, 40, 40); // Create an equilateral rectangle (square) that is 40 x 40 pixels at the point (40,40)

  pushMatrix(); //Let the compiler know that you will be modifying the Matrix
  rotate(radians(45)); // Rotate the screen about the origin (by default) 45 degrees clockwise
  fill(0); // Color the following rectangle black
  rect(40, 40, 40, 40); // Draw an equivalent rectangle as the last one, only at the new modified screen coordinates
  popMatrix(); // Let the compiler know you are done modifying the matrix
}

上述代码将创建两个相同的方形,一个位于点(40 40),一个位于起点45度左右的正时速。

There is a really detailed tutorial out there that can be found here which explains everything in much greater detail. I really hope this helps. All the best! API Reference: processing.org/reference/





相关问题
How to add/merge several Big O s into one

If I have an algorithm which is comprised of (let s say) three sub-algorithms, all with different O() characteristics, e.g.: algorithm A: O(n) algorithm B: O(log(n)) algorithm C: O(n log(n)) How do ...

Grokking Timsort

There s a (relatively) new sort on the block called Timsort. It s been used as Python s list.sort, and is now going to be the new Array.sort in Java 7. There s some documentation and a tiny Wikipedia ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Enumerating All Minimal Directed Cycles Of A Directed Graph

I have a directed graph and my problem is to enumerate all the minimal (cycles that cannot be constructed as the union of other cycles) directed cycles of this graph. This is different from what the ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签