How to resolve the algorithm Faces from a mesh step by step in the J programming language

Published on 12 May 2024 09:40 PM
#J

How to resolve the algorithm Faces from a mesh step by step in the J programming language

Table of Contents

Problem Statement

A mesh defining a surface has uniquely numbered vertices, and named, simple-polygonal faces described usually by an ordered list of edge numbers going around the face,

For example: External image of two faces Rough textual version without edges: any of all the rotations of those ordered vertices. of their rotations. Let's call the above the perimeter format as it traces around the perimeter. A separate algorithm returns polygonal faces consisting of a face name and an unordered set of edge definitions for each face. ascending order. For example face A could be described by the edges (1, 11), (7, 11), and (1, 7) (The order of each vertex number in an edge is ascending, but the order in which the edges are stated is arbitrary). Similarly face B could be described by the edges (11, 23), (1, 17), (17, 23), and (1, 11) in arbitrary order of the edges. Let's call this second format the edge format.

  1. Write a routine to check if two perimeter formatted faces have the same perimeter. Use it to check if the following pairs of perimeters are the same:
  2. Write a routine and use it to transform the following faces from edge to perimeter format. Show your output here.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Faces from a mesh step by step in the J programming language

Source code in the j programming language

edge_to_node=: 3 :0
 assert. 2 = #/.~ , y [ 'expect each node to appear twice'
 oel=. 1 2 {. y
 Y=. }. y
 while. # Y do.
  i =. <. -: 1 i.~ , Y (e."1) {: oel
  assert. 0 < # i [ 'isolated edge detected'
  oel =. oel , i { Y
  Y =. i ({. , (}.~ >:)~) Y
 end.
 ~. , oel
)


  

You may also check:How to resolve the algorithm Truncate a file step by step in the Phix programming language
You may also check:How to resolve the algorithm QR decomposition step by step in the PowerShell programming language
You may also check:How to resolve the algorithm Scope modifiers step by step in the M2000 Interpreter programming language
You may also check:How to resolve the algorithm Twelve statements step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Command-line arguments step by step in the Raku programming language