/ proof-of-concept / bead-percussion
Sign in
proof-of-concept / bead-percussion
bead-percussion / matlab / helpers / bp_chain.m
10 lines · 409 BBlameHistoryRaw
1function [pos, E, trip] = bp_chain(n, len)
2% BP_CHAIN A straight line of n beads along x, from 0 to len.
3% [pos, E] = bp_chain(n, len) returns positions (n-by-3) and the n-1
4% neighbor pairs E. The end beads are 1 and n. trip lists the n-2
5% bending triplets [i-1 i i+1] (for sys.bends).
6x = linspace(0, len, n)';
7pos = [x, zeros(n, 2)];
8E = [(1:n-1)', (2:n)'];
9trip = [(1:n-2)', (2:n-1)', (3:n)'];
10end
↑↓ move↵openescclose