The Stack Overflow podcast is back! Listen to an interview with our new CEO.

New answers tagged

6

What you describe is known as the shoelace formula. It has previously been implemented by J.M. here. I can find no way to improve on J.M.'s implementation, so I will simply repeat it: pts = CirclePoints[6]; area = Total[Det /@ Partition[pts, 2, 1, 1]]/2 (3 Sqrt[3])/2 Area@Polygon@pts (3 Sqrt[3])/2 Another implementation is provided by Chip Hurst ...


0

Amplifying on Bill's answer Legended[ Show[ RegionPlot[ x >= 5 && y >= 8 && x + 2 y <= 64 && x + y <= 40, {x, 0, 40}, {y, 0, 35}, Frame -> True, FrameLabel -> (Style[#, 14, Bold] & /@ {x, y}), PlotPoints -> 100], ContourPlot[ Evaluate[ Tooltip /@ {x == 5, y == 8, x + 2 y == 64, x +...


0

Try Show[ ...yourexistingplot..., ContourPlot[{x == 5, y == 8, x + 2y == 64, x + y == 40},{x,5,35},{y,5,30}] ] which should overlay your two plots and show you your colored lines along the edges. You can adjust the PlotRange option as needed to frame the plots.


0

Hope the following clarifies how quarter disks centered at {0,0}, {1,0}, {1,1} and {0,1} can be constructed using a single parameter: Manipulate[Graphics[{EdgeForm[{Opacity[1], Thick, Orange}], Opacity[.3], Orange, Disk[{0, 0}, 1, {0, θ}], EdgeForm[{Opacity[1], Thick, Blue}], Blue, Disk[{1, 1}, 1, {-Pi, -Pi + θ}], EdgeForm[{Opacity[1], Thick, ...


1

In the OP, the hexagon shape is defined by these points (inside Polygon in the example): hexpoints = Table[{Cos[n Pi/3], Sin[n Pi/3]}, {n, 6}] (* {{1/2, Sqrt[3]/2}, {-(1/2), Sqrt[3]/2}, {-1, 0}, {-(1/2), -(Sqrt[3]/2)}, {1/2, -(Sqrt[3]/2)}, {1, 0}} *) These make a hexagon shape with ListPlot: ListPlot[hexpoints, PlotStyle -> PointSize[Large], ...


3

FullSimplify providing the information that "the lengths a, b, and c are positive numbers such that each of them is less than the sum of the other two." assumptions = {a > 0, b > 0, c > 0, a + b > c, a + c > b, b + c > a}; FullSimplify[Insphere[SSSTriangle[a, b, c][[1]]], Assumptions -> assumptions] Sphere[{1/2 (-a + b + c), 1/2 ...


8

pts = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; ClearAll[p, nextpt, redsquares, greensquares] nextpt = AssociationThread[pts, RotateRight[pts]]; p[m_] := Tuples[{SparseArray[DiamondMatrix[m - 1]]["NonzeroPositions"] - m, pts}] redsquares[t_, m_] := Rotate[Rectangle[], t + Pi/2, #] & /@ DeleteDuplicates[Total /@ p[m]] greensquares[t_, m_] := Translate[...


10

Extending @ MelaGo answer...in spirit of OP...but needs improvement: square = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; f[j_, k_] := Table[{u, k}, {u, -j, j}]; top[n_] := Join @@ (f @@@ Table[{n - j, j}, {j, 0, n}]); bot[n_] := Join @@ (f @@@ Table[{n - j, -j}, {j, 1, n}]); full[n_] := Join[top[n], bot[n]]; funr[p_] := RegionCentroid[Polygon[RotationTransform[Pi/2,...


Top 50 recent answers are included