[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
where to cut wood
From: |
Emanuel Berg |
Subject: |
where to cut wood |
Date: |
Thu, 01 Sep 2022 21:45:46 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Where do you cut wood now that you aren't allowed to do that
in the machine shop anymore (or 'engineering workshop' to you
UK guys)?
The anser is <drumroll> at:
l*n + (b/2)(2n - 1)
It's called algebra, as we see it works well with STATIC
entities! :))
;;; -*- lexical-binding: t -*-
;;
;; this file:
;; https://dataswamp.org/~incal/emacs-init/wood.el
(require 'cl-lib)
;; Where do you cut a piece of wood if the parts should be
;; length l and the blade is width b?
;;
;; For n cuts in n = 1, 2, ... the cuts should be at:
;;
;; l*n + (b/2)(2n - 1)
;;
;; So for 3 parts of 60 cm each and a 3 mm blade cuts are made
;; at 60.15, 120.45 and 180.75 cm.
(defun cut-2 (len &optional num blade)
(or blade (setq blade 0.3))
(or num (setq num 1))
(when (> num 0)
(let ((hb (/ blade 2.0) ))
(+ (* len num)
(* hb (1- (* 2 num))) ))))
;; (cut-2 60 1) ; 60.15
;; (cut-2 60 2) ; 120.45
;; (cut-2 60 3) ; 180.75
(defun cut (len &optional blade n)
(or blade (setq blade 0.3))
(or n (setq n 3))
(cl-loop repeat n
with cuts
with pos = 0
with hb = (/ blade 2.0)
do (cl-incf pos (+ len hb))
(push pos cuts)
(cl-incf pos hb)
finally return (nreverse cuts)) )
;; (cut 60) ; (60.15 120.45 180.75)
--
underground experts united
https://dataswamp.org/~incal
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- where to cut wood,
Emanuel Berg <=