ホーム » 検索結果: QR コード

検索結果: QR コード

2024年4月
 123456
78910111213
14151617181920
21222324252627
282930  

カテゴリー

アーカイブ

ブログ統計情報

  • 80,438 アクセス



QR コード生成 – 3

今まで幾つかの所でサイトのアドレスの表示に使用してきた.
QRcode Perl CGI & PHP scripts ver. 0.50
これを他で使えないかと調べていると…

  1. 引数がうまく渡せない.2 つ目以降が無視されているような感じ.
  2. 100 文字位を超えると正しく表示できない.

どうも php の呼び出し方が悪かったみたいで,…/qr_img.php に与える引数を変更.

{
	p_data	=	p_data.substr(0,106) ;
	var	last_p	=	p_data.lastIndexOf('&') ;
	if (last_p > 0) {
		p_data	=	p_data.substr(0,last_p) ;
		}
	s_data	=	p_data ;
	p_data	=	escape		(p_data) ;
	p_data	=	"?d="	+	 p_data	;
//	p_data	=	p_data	+	"&e=M"	 ;
	}

使い方は以前と同様で .js のパスを変更.
<script src ="//itl.mydns.jp/_lib/js/i_lib/2022.01/c_qr_img.js"> </script>
<script> call_qr_img_href() ; </script>

<script src ="//itl.mydns.jp/_lib/js/i_lib/2022.01/c_qr_img.js"> </script>
<script> call_qr_img_href() ; </script>

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

QR コードが表示されない?

いつからなのか不明だが,DS116 上の qr_img.php を使用している所で正しく表示されなくなっていた.
気付いたのは昨日の昼頃.

DS115j 上や,//itools.hp2.jp/Test/qr/ のものはうまく動作している.
//itools.hp2.jp/ は DS116 上のものを利用しているのでうまく表示されない.


「Web Station」-「PHP 設定」で,「PHP エラーメッセージ表示…」にチェック.

すると,次の様なエラー.
 Fatal error: Call to undefined function ImageCreate() in /…/php/qr_img.php on line 609
検索すると GD が動作していないとのこと.
gd にチェックを付けてうまく動作する様になった.
OFF にした覚えはないので,DS116 上の何かの更新で無効になってしまったのか?

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

QR コード生成 – 2

次のコードを html 内に追加することで,html のを参照する QR コードを表示できます.

<script src ="//itl.mydns.jp/_lib/js/i_lib/2022.01/c_qr_img.js"> </script>
<script> call_qr_img_href() ; </script>

SiteMix ではうまく動作しなくなってしまいました.
以下は,以前の情報です.考え方などはそのまま使えるため残しています.


以前設定した「QR コード生成」を,もう少し汎用的に.
先ず,PHP が利用できるフリーのサーバを用意.
  SiteMix を利用.
  //itools.hp2.jp として登録.
QRcode Perl CGI & PHP scripts ver. 0.50」をサーバーに転送.
  
c_qr_img.js を転送.
  
これを利用したページ.
  //itools.hp2.jp/Test/qr/index.html


次の様なスクリプトを HTML の表示したいところに挿入する.
  <script src =”/Test/qr/c_qr_img.js” > </script>
  <script> call_qr_img_href() ; </script>
  <script> call_qr_img_free(“http://itl.mydns.jp”) ; </script>


src=”/Test/qr/c_qr_img.js” の部分は,”//itools.hp2.jp/Test/qr/c_qr_img.js” でテスト可能.
最終的には c_qr_img.js の次の所を,利用環境に合わせて編集してください.
   var domain = “//itools.hp2.jp” ;
   var qr_php = domain + “/Test/qr/qr_img/php/qr_img.php” ;




うまく動作しない時のチェック方法
QR コードが表示されない場合

JavaScript 内の qr_img.php の呼び出しが間違っている可能性があります.
ブラウザによっては「要素を調査」などで php を呼び出している部分を確認できます.


何も表示されない場合
JavaScript 自体をうまく呼び出せてない可能性があります.
html 内の呼び出し部分を確認してください.


c_qr_img.js

function	call_qr_img_php  (data,is_draw_data)
{
	var	domain	= 	"//itools.hp2.jp" ;
	var	qr_php	=	domain	+  "/Test/qr/qr_img/php/qr_img.php" ;
	{
		var	qr_img	=  "<img  src='"  +  qr_php  +  "?d="  +  data  +  "'>" ;
		document.write	(qr_img) ;
		}
	if (is_draw_data) {
		document.write	("<br/>") ;
		document.write	(data) ;
		}
	}

function	call_qr_img_href ()
{
	var	href	=	location.href ;
	call_qr_img_php	(href,true) ;
	}

function	call_qr_img_free (freeText)
{
	call_qr_img_php	(freeText,true) ;
	}

2018/06/29 追記
https に移行した関係で,SiteMix ではうまく動作しなくなってます.


2021/07/14 qr_img.php を呼出す JavaScript を修正

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

QR コード挿入のテスト

<div style=”text-align: center;”>
<script src =”/_lib/js/i_lib/2017.12/c_qr_img.js” > </script>
<script> call_qr_img_href() ; </script>
</div>



Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

QR コード生成

QRコードをどこかで使えないかと思いちょっと調べてみた.


先ず読取りから.
moto g5 や 107SH での読取りは,「公式QRコードリーダー”Q”」が良さそう.
 「機能一覧」には「読み取り内容コピー」とある.


今度は生成.
15 年位前に一度調べて,何か面倒そうなイメージがあったが…
検索すると,Y.Swetakeさんの「QR code CGI & PHP scripts」が多くヒットする.
QRcode Perl CGI & PHP scripts ver. 0.50」が最新の様で,「ver. 0.50j ( 2013/5/18)」をダウンロード.
それを解凍し,//ds115j/…/qr/qr_img/ 以下にコピー.
//…/php/qr_img.php を開くと,
 Fatal error: QRcode : Data do not exist. in /…/qr/qr_img/php/qr_img.php on line 88
 「QRcode Perl … トラブルシューティング」を見ると,qr_img.php?d=address とする必要があるとのこと.
 README.sjis にもちゃんと書いてある.


読取りでアドレスをメールなどで送信する方法は見つけた.
「設定」の中の「開く前に確認メッセージを表示」にチェックを付ける.
読取り後の確認画面に,「コピー」や「共有」のメニューが表示される.


2018/01/26 JavaScript 経由で,qr_img.php を呼び出し


2021/07/14 qr_img.php を呼出す JavaScript を修正



* QRコードは(株)デンソーウェーブの登録商標です.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

XFREE c_qr_img.js

XFREE を申し込んだもう一つの目的.
以前 SiteMix で PHP の動作を利用していたが,うまく動作しなくなってそのままだった.


次の様なコードを html 内に埋め込むことで QR コードを表示することができる.
<script src ="//mish.php.xdomain.jp/qr/c_qr_img.js" > </script>
<script> call_qr_img_href() ; </script>
c_qr_img.js の呼出し


ここまでやって気づいたのが https にできない.
また,別の所を探すか?


* QRコードは(株)デンソーウェーブの登録商標です.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Jetpack Boost の影響?

このページもそうだが,
WordPress のページにつけている「QR コード」が意図した位置に表示されていないことに気づいた.


先日,表示が速くなるかなと思い「Jetpack Boost」の設定を変更した.
どうもこれが影響していたみたい.
Jetpack Boost 「必須ではない JavaScript を後回しに」
「必須ではない JavaScript を後回しに」の機能を「OFF」に.


* QRコードは株式会社デンソーウェーブの登録商標です.
https://www.qrcode.com/faq.html#patentH2Title


Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

JavaScript module Three.js

前回 Three.jsバージョンを更新 した時に気づいていたがそのままになっていたので少し調べてみた.
きっかけは,今まで r109 だったものを r131 にしようかと …
three.module.js は r83 ぐらい? example が module 対応になったのは r105 の頃か?
r105 と r106 の ./example/js/loaders/OBJLoader.js の内容は同じ.
./webgl_loader_obj_mtl.html は import 部分と THREE が異なる.JavaScript のコードとしては同じ?


次の所を参考に,いろいろと…
JavaScript モジュール
そこにある basic-modules を,import でない方法で書き直し.
main.js を html 内の body に取り込み.
最初,間違って head 内に書いたら create でエラー(document.body が null).
また,canvas.js 内に export が存在するとうまくいかず,js をコピーして,その行をコメントに.
script src=".../canvas_.js"
それを import を使用した方法に.
main.js を直接 body 内に記述したもの.
script type="module"


*.js をどちらの場合も同じものとしたいが,方法は?


2021/06/06
Three.js で,同じ OBJLoader.js を使っているのかと思ったが,違った.
example/js/OBJLoader.js と example/jsm/OBJLoader.js が存在している.


ある程度 module を使うための変更内容がわかったので,既存のデータを変更してみた.
データはいつもの.http://mish.work/i_Tools/Doc/blog/3D_Data/Cube_2021_07.htm
r109 を利用している.それを r131 に変更.
r131 に変更したもの
c_3js_10.js の先頭に次のもの追加.

import	* as THREE        	from '/_lib/js/webgl/threejs/r131/build/three.module.js';
import	{ OrbitControls } 	from '/_lib/js/webgl/threejs/r131/examples/jsm/controls/OrbitControls.js';
import	{ MTLLoader }     	from '/_lib/js/webgl/threejs/r131/examples/jsm/loaders/MTLLoader.js';
import	{ OBJLoader }     	from '/_lib/js/webgl/threejs/r131/examples/jsm/loaders/OBJLoader.js';

最後に以下を追加.

export	{	ThreeStart10	} ;
export	{	ThreeStartF 	} ;

html を type="module" と import …/c_3js_10.js に.

<script	type="module">
	import	{	ThreeStart10	}	from	"./c_3js_10.js" ;

type module , import
実行すると幾つかのエラー.

Uncaught TypeError: THREE.OrbitControls is not a constructor
    Set_orbit http://mish.work/i_Tools/Doc/blog/3D_Data/c_3js_10.js:137
    ThreeStart10 http://mish.work/i_Tools/Doc/blog/3D_Data/c_3js_10.js:47
    <anonymous> http://mish.work/i_Tools/Doc/blog/3D_Data/Cube_2021_08.htm:42

Uncaught TypeError: THREE.OrbitControls is not a constructor
OrbitControls などクラスの利用部分が違う.THREE. の部分を削除.
THREE. 部分を削除
module を使用した方法に変更
表示されている QR コードは,以前 WebGL が動作しない環境の時の区別のためのもの.
これはうまく使えないみたいなので,その部分は削除.他に “use strict”; なども削除.
module を使用


html の script の部分で type="module" が指定されていないと,

Uncaught SyntaxError: import declarations may only appear at top level of a module Cube_2021_08_E2.htm:19:3

type="module" が指定されていない時のエラー

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

amp_preconnect_polyfill_404 …

Web サーバのログを見ていると,
404 /amp_preconnect_polyfill_404_or_other_error_expected._Do_not_worry_about_it?1553496120000
amp_preconnect_polyfill_404_or_other_error_expected
「心配しなくて良い」とあるが,気になってしまう.
amp_preconnect_polyfill_404_or_other_error_expected QR
QR コードを表示している関係か?

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

PHP 5.6 から 7.0 へ

以前調べた時,何かうまくない部分があったように思うが…
php.net PHP 5.6.x から PHP 7.0.x への移行
Synology NAS では簡単に戻せるので,7.0 に変更してみた.
設定は,DSM の「Web Station」.
ついでに,Apache も 2.4 に.

PHP 7 への設定
PHP 7 への設定

簡単に動作を確認していると,QR コードが表示されなくなっている.
この時と同じ現象,原因.
GD が動作していなかった.
gd を有効に
gd を有効に


2018/12/26
「Apache HTTP Server 2.4」では一部 500 となってしまうものがあり.
ちょっと調べる時間が取れないので 2.2 に戻すことに.
一部の .htaccess の中身がうまくなかった様で修正.
IndexIgnore となっていて,IndexIgnore * の様にファイルが指定されていなかった.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

OPENFILENAME

コンソール AP では,標準入力を使用していた.

#include	"quotm.hxx"
#include	"existff.hxx"

inline	bool	Test	(void)
{
	while(true)	{
		tstring	str ;
		{
			tstring	buf ;
			buf.resize(1000) ;
			std::terr << _T("file ...=") ;
			std::tin.getline(&buf[0],std::streamsize(buf.size())) ;
			str = buf.c_str() ;
			if   	(str == _T("q"))	{	break ;		}
			else if (str == _T("Q"))	{	break ;		}
			str = ::QuotM_Del_All(str) ;
			if (str.empty())   		{	continue ;	}
			}
		{
			if (::File_IsNothing(str)) 	{	continue ;	}
			std::tout << str << std::endl ;
			}
		}
	return	true ;
	}

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	{
		Test() ;
		}
	return	0 ;
	}

以前作成した CFileDialog を使用したもの.

#include	<afxwin.h>
#include	"F_Dialog.hxx"
#include	"quotm.hxx"

inline	bool	Test	(void)
{
	while(true)	{
		tstring	str ;
		{
			str = ::FD_GetOpenFile(_T("./")) ;
			if (str.empty())   		{	break ;		}
			}
		{
			if (::File_IsNothing(str))	{	continue ;	}
			std::tout << str << std::endl ;
			}
		}
	return	true ;
	}

CWinApp theApp;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) {
		std::terr << _T("error : AfxWinInit") << std::endl ;
		nRetCode = 1;
		}
	else  {
		Test() ;
		}
	return nRetCode;
	}

////////////////////////////////////////////////////////////////////////////////////////

#include	<AfxExt.h>
#include	"BrowseFF.cxx"

「開く」ダイアログを表示するだけのコード.

{
	OPENFILENAME	ofn =	{	0	} ;
	ofn.lStructSize = sizeof(OPENFILENAME) ;
	if (!::GetOpenFileName(&ofn))	{	return	tstring() ;	}
//	...
	}

OPENFILENAME の指定が複雑なので,使いそうな内容でまとめてみた.

OPENFILENAME
lStructSize sizeof(OPENFILENAME)
hwndOwner NULL の時,モードレスになる.
CFileDialog では DoModal で求めている.
lpstrFile 選択されたファイル名が入る.
OFN_ALLOWMULTISELECT の場合は,下のメモリイメージ.
nMaxFile lpstrFile で確保している領域の文字数

OFN_ALLOWMULTISELECT の場合の結果の lpstrFile .

0x02C00078  44 3a 5c 44 6f 63 75 6d 65 6e 74 5c 56 53 5c 56  D:\Document\VS\V
0x02C00088  53 5c 32 30 30 35 5c 54 5f 4f 70 65 6e 46 5c 54  S\2005\T_OpenF\T
0x02C00098  5f 4f 46 5f 4d 46 43    54 5f 4f 46 5f 4d 46 43  _OF_MFC.T_OF_MFC
0x02C000A8  2e 42 41 4b    54 5f 4f 46 5f 4d 46 43 2e 63 70  .BAK.T_OF_MFC.cp
0x02C000B8  70    54 5f 4f 46 5f 4d 46 43 2e 76 63 70 72 6f  p.T_OF_MFC.vcpro
0x02C000C8  6a    54 5f 4f 46 5f 4d 46 43 2e 76 63 70 72 6f  j.T_OF_MFC.vcpro
0x02C000D8  6a 2e 5a 31 37 30 53 30 2e 49 77 61 6f 2e 75 73  j.Z170S0.Iwao.us
0x02C000E8  65 72       00 00 00 00 00 00 00 00 00 00 00 00  er..............

0x027E6B50  44 00 3a 00 5c 00 44 00 6f 00 63 00 75 00 6d 00 65 00 6e 00 74 00 5c 00 56 00 53 00 5c 00 56 00  D:\Document\VS\V
0x027E6B70  53 00 5c 00 32 00 30 00 30 00 35 00 5c 00 54 00 5f 00 4f 00 70 00 65 00 6e 00 46 00 5c 00 54 00  S\2005\T_OpenF\T
0x027E6B90  5f 00 4f 00 46 00 5f 00 4d 00 46 00 43 00 00 00 54 00 5f 00 4f 00 46 00 5f 00 4d 00 46 00 43 00  _OF_MFC.T_OF_MFC
0x027E6BB0  2e 00 42 00 41 00 4b 00 00 00 54 00 5f 00 4f 00 46 00 5f 00 4d 00 46 00 43 00 2e 00 63 00 70 00  .BAK.T_OF_MFC.cp
0x027E6BD0  70 00 00 00 54 00 5f 00 4f 00 46 00 5f 00 4d 00 46 00 43 00 2e 00 76 00 63 00 70 00 72 00 6f 00  p.T_OF_MFC.vcpro
0x027E6BF0  6a 00 00 00 54 00 5f 00 4f 00 46 00 5f 00 4d 00 46 00 43 00 2e 00 76 00 63 00 70 00 72 00 6f 00  j.T_OF_MFC.vcpro
0x027E6C10  6a 00 2e 00 5a 00 31 00 37 00 30 00 53 00 30 00 2e 00 49 00 77 00 61 00 6f 00 2e 00 75 00 73 00  j.Z170S0.Iwao.us
0x027E6C30  65 00 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  er..............

lpstrFile	0x02c10078 "D:\Document\VS\VS\2005\T_OpenF\T_OF_MFC\ReadMe.txt"	char *

デバッガで OPENFILENAME_SIZE_VERSION_400 となる様にしたもの.
OPENFILENAME_SIZE_VERSION_400


MFC 9 で bVistaStyle を FALSE とすると
CFileDialog bVistaStyle == FALSE
VC 8 exe と同様の,左側がフォルダツリーではない表示のもの.
デフォルトの TRUE だと
CFileDialog bVistaStyle == TRUE
COM を利用したもの?
Common Item Dialog


今度は MFC を使用しない方法.
::GetOpenFileName を使用する方法で OFN_ALLOWMULTISELECT を指定すると実行されなかった.
見た目のエラーにはならない?が,API を呼んで FALSE で抜けてくる.
::CommDlgExtendedError で調べると FNERR_INVALIDFILENAME だった.
存在しないファイル名などを与えるとうまくないみたい.
まだ何か足りないみたいで Win3.x 頃の表示になってしまった.
GetOpenFileName  Win3.x
選択したファイル名などもスペースで区切られている.
OFN_ALLOWMULTISELECT を指定する時は OFN_EXPLORER も指定する必要があるみたい.
次の所に書かれていた.
OPENFILENAMEW structure (commdlg.h)
OFN_ALLOWMULTISELECT | OFN_EXPLORER の場合 lpstrFile に存在しないファイル名でも問題なさそう.


複数選択可能な「開く」ダイアログのコードは次の様な感じ.

tstring	GetOpenFile	(LPCTSTR default_name=_T("./"))
{
	HWND	hwnd = ::GetConsoleHwnd() ;
	tstring	str_file = default_name ;
	    	str_file.resize(260*100) ;
	OPENFILENAME	ofn =	{	0	} ;
	{
		ofn.lStructSize	= sizeof(OPENFILENAME) ;
		ofn.hwndOwner	= hwnd ;
		ofn.nMaxFile	= DWORD(str_file.size()) ;
		ofn.lpstrFile	= &str_file[0] ;
		ofn.Flags   	= OFN_ALLOWMULTISELECT | OFN_EXPLORER | OFN_HIDEREADONLY ;
		}
	if (!::GetOpenFileName(&ofn)) {
		DWORD	err = ::CommDlgExtendedError() ;
		std::terr << ::To_tstring(u_32(err),16) << std::endl ;
		return	tstring() ;
		}
	tstring	sel_file ;
	{
		sel_file = ofn.lpstrFile ;
	//	...
		}
	return	sel_file ;
	}

拡張子のフィルタなどは指定していない.また,選択されたファイルを取得するコードもこれから.


選択されたファイルを取得するコード.

tstring	String_Change	(c_tstring& str_,const TCHAR src,const TCHAR dst)
{
	tstring	str = str_ ;
	for (size_t index=0 ; index<str.size() ; index++) {
		TCHAR	ch = str[index] ;
		if (ch == src) {
			str[index] = dst ;
			}
		}
	return	str ;
	}

	tstring	sel_file ;
	{
		sel_file = ofn.lpstrFile ;
		sel_file = str_file ;
		sel_file = ::String_Change(ofn.lpstrFile,_T('\x0'),_T('\n')) ;
		sel_file = ::String_Change(str_file,     _T('\x0'),_T('\n')) ;
		sel_file = ::String_TrimBoth(sel_file) ;
		}

ofn.lpstrFile は ASCIIZ となってしまうので,str_file をそのまま使用する必要がある.
Win3.x 形式の lpstrFile のダンプ.

0x02311F00  0043 003a 005c 0055 0053 0045 0052 0053 005c 0050 0055 0042 004c 0049 0043 005c  C.:.\.U.S.E.R.S.\.P.U.B.L.I.C.\.
0x02311F20  0044 004f 0043 0055 004d 0045 004e 0054 0053 005c 0020 0042 0061 0063 006b 0043  D.O.C.U.M.E.N.T.S.\. .B.a.c.k.C.
0x02311F40  0050 002e 0062 0061 0074 002e 006c 006e 006b 0020 0057 0049 004e 0031 0030 002d  P...b.a.t...l.n.k. .W.I.N.1.0.-.
0x02311F60  007e 0031 002e 004c 004e 004b 0020 005a 0031 0037 0030 0044 004f 007e 0031 002e  ~.1...L.N.K. .Z.1.7.0.D.O.~.1...
0x02311F80  004c 004e 004b 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  L.N.K...........................

区切りがスペースになるため,ファイル名などにスペースが含まれている場合は 8.3 形式 になる.


lpstrFilter を指定.

	tstring	filter ;
		filter	+= _T("Executable Files (*.exe)|*.exe|") ;
		filter	+= _T("All Files (*.*)|*.*|") ;
		filter	+= _T("|") ;
		filter   = ::String_Change(filter,_T('|'),_T('\x0')) ;
	OPENFILENAME	ofn =	{	0	} ;
	{
		ofn.lStructSize	= sizeof(OPENFILENAME) ;
	//	...
		ofn.lpstrFilter	= &filter[0] ;
		}

ここまでのものを WinXP 環境で表示すると
GetOpenFileName WinXP


WFDialog.hxx

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

弦と矢と半径 – 9

JavaScript で.

<body>
	c : <input	type='number'	id='in__c'	value='80.0'	size='10'	step='any'	/><input	type='submit'	value='c_rs'	id='c_rs'	/>	<span	id='out_c'> </span>	<br />
	s : <input	type='number'	id='in__s'	value='20.0'	size='10'	step='any'	/><input	type='submit'	value='s_rc'	id='s_rc'	/>	<span	id='out_s'> </span>	<br />
	r : <input	type='number'	id='in__r'	value='50.0'	size='10'	step='any'	/><input	type='submit'	value='r_cs'	id='r_cs'	/>	<span	id='out_r'> </span>	<br />
	<img	src='r_cs.png'	width='300px'>

	<script>
		function	r_cs	(c , s)		{	return	(        ( c*c )  / ( 8*s )  +  s/2 ) ;		}
		function	s_rc	(r , c)		{	return	( r-Math.sqrt(r*r - (c/2)*(c/2) )   ) ;		}
		function	c_rs	(r , s)		{	return	(   Math.sqrt(r*r - (r-s)*(r-s) )*2 ) ;		}

		function	f_c_rs	() {
			var	oc = document.querySelector("#out_c") ;
			var	os = document.querySelector("#out_s") ;
			var	or = document.querySelector("#out_r") ;
			var	ic = document.querySelector("#in__c") ;
			var	is = document.querySelector("#in__s") ;
			var	ir = document.querySelector("#in__r") ;
			var	fc = parseFloat(ic.value) ;
			var	fs = parseFloat(is.value) ;
			var	fr = parseFloat(ir.value) ;
			oc.textContent = "" ;
			os.textContent = "" ;
			or.textContent = "" ;
			oc.textContent = c_rs(fr,fs) ;
			}
		//	...
		{
			var	ec = document.getElementById("c_rs") ;
			var	es = document.getElementById("s_rc") ;
			var	er = document.getElementById("r_cs") ;
			ec.addEventListener("click",f_c_rs, false) ;
			es.addEventListener("click",f_s_rc, false) ;
			er.addEventListener("click",f_r_cs, false) ;
			}
		</script>
	</body>

R S C JavaScript
https://mish.myds.me/…/r_cs/9/

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

弦と矢と半径 – 6

Python のコードを修正して「結果のみ」を出力する様に変更.

import	sys
import	math

def	r_cs	(c , s)	:	return	(        ( c*c )  / ( 8 *s ) +  s/2 )
def	s_rc	(r , c)	:	return	( r-math.sqrt(r*r - (c/2)*(c/2) )   )
def	c_rs	(r , s)	:	return	(   math.sqrt(r*r - (r-s)*(r-s) )*2 )

cmd =       sys.argv[1]
p1  = float(sys.argv[2])
p2  = float(sys.argv[3])

#print	(cmd + " " + str(p1) + " " + str(p2))

if  	cmd == "r_cs"	:	print	(r_cs(p1,p2))
elif	cmd == "s_rc"	:	print	(s_rc(p1,p2))
elif	cmd == "c_rs"	:	print	(c_rs(p1,p2))
#else	            	:	print	("error")

#print	("")

弦と矢と半径 スマートフォンからアクセス
PHP
あまり綺麗なコードでないので,ここには張り付けていません.リンク先を見てください.
PHP から Python の呼び出し
https://mish.myds.me/…/r_cs/6/

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

弦と矢と半径 – 5

PHP から Python の呼び出しで,Python のコマンドライン引数を使用する.

<?php

	echo	("call python\n") ;

	echo	("\n") ;
	system	("python r_cs.py r_cs 6 1") ;
	system	("python r_cs.py s_rc 5 6") ;
	system	("python r_cs.py c_rs 5 1") ;

	echo	("\n") ;
	system	("python r_cs.py r_cs 8 2") ;
	system	("python r_cs.py s_rc 5 8") ;
	system	("python r_cs.py c_rs 5 2") ;

	?>

Python のコードは,

import	sys
import	math

def	r_cs	(c , s)	:	return	(        ( c*c )  / ( 8 *s ) +  s/2 )
def	s_rc	(r , c)	:	return	( r-math.sqrt(r*r - (c/2)*(c/2) )   )
def	c_rs	(r , s)	:	return	(   math.sqrt(r*r - (r-s)*(r-s) )*2 )

cmd =       sys.argv[1]
p1  = float(sys.argv[2])
p2  = float(sys.argv[3])

print	(cmd + " " + str(p1) + " " + str(p2))

if  	cmd == "r_cs"	:	print	(r_cs(p1,p2))
elif	cmd == "s_rc"	:	print	(s_rc(p1,p2))
elif	cmd == "c_rs"	:	print	(c_rs(p1,p2))
else	            	:	print	("error")

print	("")

Python がよくわかっていないので,いろいろなエラーが…
PHP から Python の呼び出し コマンドライン引数
https://mish.myds.me/…/r_cs/5/

弦,矢,半径

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

内積で誤差?

以前書いたコードで次の様にしていた.

デバッグ版では単位ベクトルにすると誤差が大きい様に感じたが,リリース版ではそれ程でもない?


double	Naiseki	(const P3& p1,const P3& p2)
{
  //	→ →  →  →
  //	a・b=|a||b|cosθ
  //	a.x*b.x+a.y*b.y+a.z*b.z=sqrt(ax*ax+ay*ay+az*az)*sqrt(bx*bx+by*by+bz*bz)*cosθ
  //	...	a,bのベクトルが単位ベクトルの時
  //		sqrt(ax...) と sqrt(bx...) は 1
  //	a.x*b.x+a.y*b.y+a.z*b.z=1*1*cosθ
  //	a.x*b.x+a.y*b.y+a.z*b.z=cosθ
  //	→ →
  //	a・b=ax*bx+ay*by+az*bz
  P3	p1u = p1.Uni() ;
  P3	p2u = p2.Uni() ;
  //	return	(p1u.x*p2u.x+p1u.y*p2u.y+p1u.z*p2u.z) ;
  //	誤差の補正
  double	dp = p1u.x*p2u.x+p1u.y*p2u.y+p1u.z*p2u.z ;
  if (dp<-1 || 1<dp) {
    if (dp < -1.)	{	dp = -1. ;	}
    if (dp >  1.)	{	dp =  1. ;	}
    }
  return	dp ;
  }
 
P3	Gaiseki	(const P3& p1,const P3& p2)
{
  //	→ →  →  →
  //	a×b=|a||b|sinθ・c
  //	→ →
  //	a×b=(ay*bz-az*by,az*bx-ax*bz,ax*by-ay*bx)
  P3	pt ;
  pt.x = p1.y * p2.z - p1.z * p2.y ;
  pt.y = p1.z * p2.x - p1.x * p2.z ;
  pt.z = p1.x * p2.y - p1.y * p2.x ;
  return	pt ;
  }
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.