<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>k-Wave User Forum &#187; Topic: Adding elements in kArray</title>
		<link>http://www.k-wave.org/forum/topic/adding-elements-in-karray</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 21:21:59 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.k-wave.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.k-wave.org/forum/rss/topic/adding-elements-in-karray" rel="self" type="application/rss+xml" />

		<item>
			<title>atandri on "Adding elements in kArray"</title>
			<link>http://www.k-wave.org/forum/topic/adding-elements-in-karray#post-9231</link>
			<pubDate>Thu, 04 Sep 2025 20:52:23 +0000</pubDate>
			<dc:creator>atandri</dc:creator>
			<guid isPermaLink="false">9231@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I am having some trouble creating sensical shapes when rotating kArray 2D elements in a 3D simulation. For example, the addRectElement makes a flat rectangle structure when the angle of rotation is [0,0,0], but with any other angle of rotation, it forms a 3D rectangular prism with + shaped structures on the end when the binary mask is visualized in volumeViewer or similar. I have found this to be the case with other element shapes as well when rotated. Is there a fix for this to obtain the expected rotated structures?&#60;/p&#62;
&#60;p&#62;Sample code:&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% DEFINE THE K-WAVE GRID&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% set the size of the perfectly matched layer (PML)&#60;br /&#62;
PML_X_SIZE = 10;            % [grid points]&#60;br /&#62;
PML_Y_SIZE = 10;            % [grid points]&#60;br /&#62;
PML_Z_SIZE = 10;            % [grid points]&#60;br /&#62;
PML_size = [PML_X_SIZE, PML_Y_SIZE, PML_Z_SIZE];&#60;br /&#62;
% set total number of grid points not including the PML&#60;br /&#62;
Nx = 256 - 2*PML_X_SIZE;    % [grid points]&#60;br /&#62;
Ny = 256 - 2*PML_Y_SIZE;     % [grid points]&#60;br /&#62;
Nz = 256 - 2*PML_Z_SIZE;     % [grid points]&#60;br /&#62;
grid_size = [Nx, Ny, Nz];&#60;/p&#62;
&#60;p&#62;% calculate the spacing between the grid points&#60;br /&#62;
dx = 2e-4;                % [m]&#60;br /&#62;
dy = dx;                    % [m]&#60;br /&#62;
dz = dx;                    % [m]&#60;/p&#62;
&#60;p&#62;% create the k-space grid&#60;br /&#62;
kgrid = kWaveGrid(Nx, dx, Ny, dy, Nz, dz);&#60;/p&#62;
&#60;p&#62;%% =========================================================================&#60;br /&#62;
% DEFINE KARRAY&#60;br /&#62;
% =========================================================================&#60;br /&#62;
karray = kWaveArray;&#60;/p&#62;
&#60;p&#62;karray.addRectElement([-6e-3,1.5e-3,0],5e-3, 2e-4, [90, 0, 0]);&#60;br /&#62;
source_mask = karray.getArrayBinaryMask(kgrid);&#60;/p&#62;
&#60;p&#62;slice(single(source_mask), 127,88,118);&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
Edit: My apologies, it seems I have submitted this under the wrong forum subject but there is no way to delete.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
