diff --git a/src/main/matlab/+strategies/+placement/verifyCosineLawCriticalAngleStrategy.m b/src/main/matlab/+strategies/+placement/verifyCosineLawCriticalAngleStrategy.m new file mode 100644 index 0000000..b945679 --- /dev/null +++ b/src/main/matlab/+strategies/+placement/verifyCosineLawCriticalAngleStrategy.m @@ -0,0 +1,16 @@ +function res = verifyCosineLawCriticalAngleStrategy(chip, n1, n2, n3) + import utils.squareIt; + + aX = n1.x - n2.x; + aY = n1.y - n2.y; + bX = n3.x - n2.x; + bY = n3.y - n2.y; + + aDotBSquared = squareIt((aX * bX) + (aY * bY)); + aSquaredBSquared = (squareIt(aX) + squareIt(aY)) * (squareIt(bX) + squareIt(bY)) + + cosineSquaredTheta = aDotBSquared / aSquaredBSquared; + cosineSquaredThetaCritical = squareIt(cos(chip.criticalCrossingAngle)); + + res = cosineSquaredThetaCritical <= cosineSquaredTheta; +end diff --git a/src/main/matlab/+strategies/+placement/verifyFiniteChipAreaRuleStrategy.m b/src/main/matlab/+strategies/+placement/verifyFiniteChipAreaRuleStrategy.m new file mode 100644 index 0000000..14c7f24 --- /dev/null +++ b/src/main/matlab/+strategies/+placement/verifyFiniteChipAreaRuleStrategy.m @@ -0,0 +1,14 @@ +function res = verifyFiniteChipAreaRuleStrategy(chip, varargin) + res = 1; + for idx = 1:numel(varargin) + node = varargin{idx}; + res = res & validateNodeCoordinates(chip, node); + end +end + +function res = validateNodeCoordinates(chip, node) + res = node.x > 0.0 & ... + node.y > 0.0 & ... + node.x < chip.maximumChipSizeX & ... + node.y < chip.maximumChipSizeY; +end diff --git a/src/main/matlab/+strategies/+placement/verifyMinimumChannelLengthStrategy.m b/src/main/matlab/+strategies/+placement/verifyMinimumChannelLengthStrategy.m new file mode 100644 index 0000000..b102bdc --- /dev/null +++ b/src/main/matlab/+strategies/+placement/verifyMinimumChannelLengthStrategy.m @@ -0,0 +1,3 @@ +function res = verifyMinimumChannelLength(chip, channel) + res = channel.len >= chip.minimumChannelLength; +end diff --git a/src/main/matlab/+strategies/+placement/verifyPythagoreanLengthRuleStrategy.m b/src/main/matlab/+strategies/+placement/verifyPythagoreanLengthRuleStrategy.m new file mode 100644 index 0000000..7837974 --- /dev/null +++ b/src/main/matlab/+strategies/+placement/verifyPythagoreanLengthRuleStrategy.m @@ -0,0 +1,5 @@ +function res = verifyPythagoreanLengthRuleStrategy(n1, n2, channel) + import utils.squareIt; + + res = squareIt(n1.x - n2.x) + squareIt(n1.y - n2.y) == channel.len; +end diff --git a/src/main/matlab/+types/Channel.m b/src/main/matlab/+types/Channel.m new file mode 100644 index 0000000..0a4bacb --- /dev/null +++ b/src/main/matlab/+types/Channel.m @@ -0,0 +1,11 @@ +classdef Channel + properties + len + end + + methods + function channel = Channel(len) + channel.len = len; + end + end +end diff --git a/src/main/matlab/+types/Chip.m b/src/main/matlab/+types/Chip.m new file mode 100644 index 0000000..814d882 --- /dev/null +++ b/src/main/matlab/+types/Chip.m @@ -0,0 +1,10 @@ +classdef Chip + properties + minimumNodeDistance + minimumChannelLength + maximumChipSizeX + maximumChipSizeY + criticalCrossingAngle + end + +end diff --git a/src/main/matlab/+types/Node.m b/src/main/matlab/+types/Node.m new file mode 100644 index 0000000..2a84e78 --- /dev/null +++ b/src/main/matlab/+types/Node.m @@ -0,0 +1,18 @@ +classdef Node + properties + % x, y are assumed to be the co-ordinates of + % the top-left edge of the node + x + y + area + end + + methods + function node = Node(x, y) + node.x = x; + node.y = y; + node.area = 0; + end + end + +end diff --git a/src/main/matlab/+utils/squareIt.m b/src/main/matlab/+utils/squareIt.m new file mode 100644 index 0000000..b4fa0ce --- /dev/null +++ b/src/main/matlab/+utils/squareIt.m @@ -0,0 +1,3 @@ +function res = squareIt(value) + res = value ^ 2; +end