Syntax
p=pgrid(x,y,lx,ly,nx,ny,[type])
Input Parameter
x : | | x-grid |
y : | | y-grid |
lx : | | x-size of the grid |
ly : | | y-size of the grid |
nx : | | number of grid points in x |
ny : | | number of grid points in y |
type : | | 0 = grid starts at 0; 1=grid starts at lx(nx)/2; default is 1 |
Output Parameter
p : | | point (1:3,1) of the grid |
Examples
Position (1,1) of a 5x5 grid as part of a 50x50mm board
pgrid(1,1,50,50,4,4,0)
Copyright 2011-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, pgrid
, is designed to calculate a point on a 2D grid. It is part of the SG-Library and can be used in conjunction with the VLFLexpboard to position objects on a grid.
Input Parameters
- x: The x-coordinate on the grid.
- y: The y-coordinate on the grid.
- lx: The total size of the grid in the x-direction.
- ly: The total size of the grid in the y-direction.
- nx: The number of grid points in the x-direction.
- ny: The number of grid points in the y-direction.
- type: (Optional) Determines the starting point of the grid. Default is 1.
Output
- p: A 3-element vector representing a point on the grid.
Algorithm Details
The function begins by setting the default value of type
to 1. If the number of input arguments is 7 or more, it assigns the seventh argument to type
.
Switch Conditions
- Case type == 1:
- Adjusts
nx
and ny
by subtracting 1 from each.
- Calculates the grid spacing
dx
and dy
by dividing lx
and ly
by nx+1
and ny+1
, respectively.
- Computes the point
p
as [-dx/2 + x*dx; -dy/2 + y*dy; 0]
.
- Case type == 0:
- Calculates the grid spacing
dx
and dy
by dividing lx
and ly
by nx
and ny
, respectively.
- Computes the point
p
as [x*dx; y*dy; 0]
.
The function returns the calculated point p
and exits.
Algorithm explaination created using ChatGPT on 2025-08-18 23:36. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21